<?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>
答案 0 :(得分:6)
您应该使用维度来克服此问题。 只需为每个密度屏幕定义尺寸。
值-LDPI / dimesion.xml
<resources>
<dimen name="grid_vertical_space">15dp</dimen>
</resources>
值-MDPI / dimesion.xml
<resources>
<dimen name="grid_vertical_space">20dp</dimen>
</resources>
值-HDPI / dimesion.xml
<resources>
<dimen name="grid_vertical_space">30dp</dimen>
</resources>
喜欢明智..
试试这个
<?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>
答案 1 :(得分:0)
如果您的布局仅由4个图标组成,为什么不使用TableLayout和2 TableRow?我认为你可以更轻松地实现你想要的东西,因为: