android Viewpager inner page margins -
i trying show images in viewpager there padding inside each page , don't know how remove it. here image shows white space around image
here xml code:
<linearlayout android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.v4.view.viewpager android:layout_width="200dp" android:layout_height="match_parent" android:layout_gravity="center" android:id="@+id/view_pager"> </android.support.v4.view.viewpager> </linearlayout> </linearlayout>
her define adapter:
public class customswipadapter extends pageradapter { private context context; private layoutinflater layoutinflater; bitmap[] bitmaps; public customswipadapter(context context, bitmap[] bitmaps) { this.context=context; this.bitmaps=bitmaps; } @override public int getcount() { return bitmaps.length; } @override public boolean isviewfromobject(view view, object object) { return (view==( linearlayout)object); } @override public float getpagewidth(int position) { return 0.7f; } @override public object instantiateitem(viewgroup container, int position) { layoutinflater=(layoutinflater)context.getsystemservice(context.layout_inflater_service); view item_view=layoutinflater.inflate(r.layout.swip_layout,container,false); imageview imageview=(imageview)item_view.findviewbyid(r.id.swip_image ); imageview.setimagebitmap(bitmaps[position]); //item_view.setpadding(0,0,0,0); item_view.setbackgroundcolor(color.argb(255, 255, 255, 255)); container.addview(item_view); return item_view; } @override public void destroyitem(viewgroup container, int position, object object) { container.removeview((linearlayout)object); } }
here show view pager in fragment:
private void compressing() { bytearrayoutputstream stream=new bytearrayoutputstream(); for(int i=0;i<icons.length;i++) icons[i].compress(bitmap.compressformat.jpeg, 40, stream); adapter=new customswipadapter(getactivity(),icons); viewpager.setadapter(adapter); viewpager.setoffscreenpagelimit(adapter.getcount()); viewpager.setpagemargin(15); viewpager.setclipchildren(false); }
Comments
Post a Comment