Reputation: 15034
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#FFFFFF"
android:layout_gravity="center"
android:padding="5dip" >
<GridView
android:id="@+id/homeGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="200dip"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:gravity="center"
android:horizontalSpacing="0dip"
android:numColumns="2"
android:stretchMode="spacingWidthUniform"
android:verticalSpacing="10dip" />
</LinearLayout>
Upvotes: 3
Views: 3041
Reputation: 5113
If your layout is composed only of 4 icons, why don't you use a TableLayout with 2 TableRow? I think you can achieve what you want more easily, because:
Upvotes: 0
Reputation: 8939
You should use dimension to overcome this issue. Just define dimension for each density screen.
values-ldpi/dimesion.xml
<resources>
<dimen name="grid_vertical_space">15dp</dimen>
</resources>
values-mdpi/dimesion.xml
<resources>
<dimen name="grid_vertical_space">20dp</dimen>
</resources>
values-hdpi/dimesion.xml
<resources>
<dimen name="grid_vertical_space">30dp</dimen>
</resources>
Like wise..
Try like this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:background="#FFFFFF"
android:layout_gravity="center"
android:padding="5dip" >
<GridView
android:id="@+id/homeGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnWidth="200dip"
android:adjustViewBounds="true"
android:layout_gravity="center"
android:gravity="center"
android:horizontalSpacing="0dip"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="@dimen/grid_vertical_space" />
</LinearLayout>
Upvotes: 6