我无法弄清楚这个左侧填充的来源。
我的网格不仅仅是未经中断,它似乎与右边对齐。怎么了?
布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView"
android:numColumns="auto_fit"
android:columnWidth="240dp"
android:stretchMode="spacingWidthUniform"
android:verticalSpacing="22dp"
android:horizontalSpacing="16dp"
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent = "true">
</GridView>
</RelativeLayout>
答案 0 :(得分:2)
我相信它来自
行android:stretchMode="spacingWidthUniform"
删除并测试它。
答案 1 :(得分:1)
试试这个标签
android:gravity="center" in GridView
作为
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView"
android:numColumns="3"// Changed to 3
android:columnWidth="60dp"
android:stretchMode="columnWidth"// Added
android:verticalSpacing="22dp"
android:horizontalSpacing="16dp"
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
>
</GridView>
</RelativeLayout>