Android 删除GridView中的所有列间距

Android 删除GridView中的所有列间距,android,android-gridview,Android,Android Gridview,我有一个应用程序,它接受可变数量的用户名,并为每个用户构建一个包含两列的网格。问题是,我希望网格中的列彼此之间没有空间。如果他们没有填满屏幕,我希望他们集中在屏幕上。我已经尝试了所有关于堆栈溢出的建议,但到目前为止没有任何效果 我更改了列宽、重力、水平间距和拉伸模式。我还缺少其他可能有用的值吗 以下是包含我的栅格视图的布局: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.Constraint

我有一个应用程序,它接受可变数量的用户名,并为每个用户构建一个包含两列的网格。问题是,我希望网格中的列彼此之间没有空间。如果他们没有填满屏幕,我希望他们集中在屏幕上。我已经尝试了所有关于堆栈溢出的建议,但到目前为止没有任何效果

我更改了列宽、重力、水平间距和拉伸模式。我还缺少其他可能有用的值吗

以下是包含我的栅格视图的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/greetPlayers"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:gravity="center"
        android:text="Player Names Here"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <GridView
        android:id="@+id/score_gridview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:columnWidth="100dp"
        android:horizontalSpacing="0dp"
        android:verticalSpacing="0dp"
        android:gravity="center"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/greetPlayers" />

    <FrameLayout
        android:id="@+id/scoreEntryWindow"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        tools:layout_editor_absoluteX="64dp"></FrameLayout>

</android.support.constraint.ConstraintLayout>


您是否尝试将android:adjustViewBounds=“true”
添加到您的GridView中?我尝试过,但它仍然具有相同的间距。当我单击一个单元格时,它也会高亮显示它旁边的空间,所以我现在想知道问题是否出在单元格本身,而不是在网格视图上填充,但不确定这是怎么回事,因为它没有添加垂直空间,图像也没有边框。为什么使用GridView而不是RecyclerView?也不要设置GridView的列宽您是否可以尝试在项目线性布局中使用
wrap\u content
,而不是
match\u parent
?同时保持android:adjustViewBounds=“true”未被触动。我将制作一些动画,我的导师说我应该使用GridView,而不是RecyclerView。我从GridView中删除了columnWidth,将android:adjustViewBounds=“true”保持不变,并在LinearLayout中将“match\u parent”更改为“wrap\u content”,我仍然可以看到间距。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="-15dp">

        <ImageView
            android:id="@+id/backgroundCellImage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/empty_square" />

        <TextView
            android:id="@+id/foregroundCellContents"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="1,1" />
    </FrameLayout>


</LinearLayout>