java - Android GridView make images fill screen -
how can make images in grid view fill screen?
here layout code:
<?xml version="1.0" encoding="utf-8"?> <gridview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/grid_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_margin="10dp" android:padding="10dp" android:columnwidth="100dp" android:gravity="center" android:horizontalspacing="10dp" android:numcolumns="auto_fit" android:stretchmode="columnwidth" android:verticalspacing="10dp" > </gridview> i post picture of screen .
but displaying images small , not using entire screen.
here adapter class:
public class menucategoryadapter extends baseadapter { private globalobjects global; private context mcontext; // keep objects in array public arraylist<menucategory> categories = new arraylist<menucategory>(); // constructor public menucategoryadapter(context c, globalobjects _global) { mcontext = c; global = _global; jsonarray categoriesobj = getcategoriesfromserver(); if (categoriesobj != null) { putcategoriesintoarray(categoriesobj); } else { // categories null log.e("imageadapter", " categories null"); } } @override public int getcount() { return categories.size(); } @override public object getitem(int position) { return categories.get(position); } @override public long getitemid(int position) { return 0; } @override public view getview(int position, view convertview, viewgroup parent) { imageview imageview = categories.get(position).getimg(); imageview.setscaletype(imageview.scaletype.center_crop); imageview.setlayoutparams(new gridview.layoutparams(70, 70)); return imageview; } }
here grid view fill screen. works me it. if happens wrong inform me immediate.
<?xml version="1.0" encoding="utf-8"?> <gridview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/grid_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:numcolumns="auto_fit" android:columnwidth="90dp" android:horizontalspacing="5dp" android:verticalspacing="5dp" android:gravity="center" android:stretchmode="columnwidth" > </gridview> also need edit in java code. make scale 70,70 fill_parant please.
i have sample app it. if require please tell me upload you.
Comments
Post a Comment