android - GridView not fit properly under Gallary -
in main screen, have gallery
, textview
, 3 x 3 gridview
, gridview
under gallery
, textview
, gridview
suppose fit on screen sizes, using s grand duos , s3 test. renders on s3, on grand duos not, on grand duos vertical spacing joined , have scroll gallery
view last row of gridview
.
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bg" android:orientation="vertical" android:weightsum="100" > <gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="40" android:adjustviewbounds="true" android:background="#000000" android:scaletype="fitxy" /> <textview android:id="@+id/mytext" android:layout_width="fill_parent" android:layout_height="20dp" android:gravity="center" android:text=" swipe view image" android:textcolor="#ffffff" android:textstyle="bold" /> <gridview android:id="@+id/grid_view" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="60" android:columnwidth="0dp" android:gravity="center" android:horizontalspacing="20dp" android:numcolumns="3" android:stretchmode="columnwidth" android:verticalspacing="10dp" > </gridview> </linearlayout> public class imageadapter extends baseadapter { private context mcontext; // keep images in array public integer[] mthumbids = { r.drawable.upcoming, r.drawable.news, r.drawable.special, r.drawable.live, r.drawable.acts, r.drawable.blogs, r.drawable.resources, r.drawable.profile, r.drawable.apps, }; // constructor public imageadapter(context c){ mcontext = c; } @override public int getcount() { return mthumbids.length; } @override public object getitem(int position) { return mthumbids[position]; } @override public long getitemid(int position) { return 0; } @override public view getview(int position, view convertview, viewgroup parent) { imageview imageview = new imageview(mcontext); imageview.setimageresource(mthumbids[position]); imageview.setlayoutparams(new gridview.layoutparams(190, 190)); return imageview; } }
u give android:weightsum 100 in text u take height u have adjust weight in child og linear layout
<gallery android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="40" android:adjustviewbounds="true" android:background="#000000" android:scaletype="fitxy" /> <textview android:id="@+id/mytext" android:layout_width="wrap_content" android:layout_height=" 0dp" android:gravity="center" android:layout_weight="20" android:text=" swipe view image" android:textcolor="#000000" android:textstyle="bold" /> <gridview android:id="@+id/grid_view" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="60" android:columnwidth="0dp" android:gravity="center" android:horizontalspacing="20dp" android:numcolumns="3" android:stretchmode="columnwidth" android:verticalspacing="10dp" > </gridview> </linearlayout>
Comments
Post a Comment