How to set Gravity of Gridview?
How to set gravity of gridview, i used the following code for that but this code is not working.
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:gravity="center"
android:layout_gravity="center_horizontal">
<GridView
android:id="@+id/grdviewmainmenu"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:verticalSpacing="10dip"
android:horizontalSpacing="17dip"
android:numColumns="auto_fit"
android:columnWidth="80dip"
android:stretchMode="spacingWidth"
android:gravity="center" />开发者_StackOverflow中文版;
</LinearLayout>
Maybe changing android:gravity="center"
to android:layout_gravity="center"
will do the job? Actually, what do you mean by "this code is not working"?
u use android:layout_gravity="center"
Use RelativeLayout instead of LinearLayout as a parent. will perfectly work...
精彩评论