Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Gridlayout没有调整大小并将自身置于屏幕中央_Android_Android Gridlayout - Fatal编程技术网

Android Gridlayout没有调整大小并将自身置于屏幕中央

Android Gridlayout没有调整大小并将自身置于屏幕中央,android,android-gridlayout,Android,Android Gridlayout,我不知道为什么我的GridLayout没有出现在屏幕中央。此外,我希望它可以调整大小,以便它可以适合任何屏幕的任何设备我使用 以下是我用来创建UI的xml: <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:

我不知道为什么我的GridLayout没有出现在屏幕中央。此外,我希望它可以调整大小,以便它可以适合任何屏幕的任何设备我使用

以下是我用来创建UI的xml:

<GridLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:stretchMode="columnWidth"
    android:useDefaultMargins="true"
    android:columnCount="4"
    >
<Spinner
        android:id="@+id/selectPlayerDropdown"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_columnSpan="4"
        />
<ImageView
        android:id="@+id/imageView0"
        android:layout_row="1"
        android:layout_column="0"
        android:background="#C0C0C0"
        />
<ImageView
        android:id="@+id/imageView1"
        android:layout_row="1"
        android:layout_column="1"
        android:background="#CCCCCC"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView2"
        android:layout_row="1"
        android:layout_column="2"
        android:background="#EEEEEE"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView3"
        android:layout_row="1"
        android:layout_column="3"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView4"
        android:layout_row="2"
        android:layout_column="0"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView5"
        android:layout_row="2"
        android:layout_column="1"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView6"
        android:layout_row="2"
        android:layout_column="2"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView7"
        android:layout_row="2"
        android:layout_column="3"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView8"
        android:layout_row="3"
        android:layout_column="0"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView9"
        android:layout_row="3"
        android:layout_column="1"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView10"
        android:layout_row="3"
        android:layout_column="2"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView11"
        android:layout_row="3"
        android:layout_column="3"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView12"
        android:layout_row="4"
        android:layout_column="0"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView13"
        android:layout_row="4"
        android:layout_column="1"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView14"
        android:layout_row="4"
        android:layout_column="2"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
<ImageView
        android:id="@+id/imageView15"
        android:layout_row="4"
        android:layout_column="3"
        android:background="#FF0000"
        android:layout_width="wrap_content"/>
这就是它看起来的样子:

也许也可以尝试将android:gravity=center添加到GridLayout?我还没有使用GridLayout,但如果我正确理解layout_gravity和gravity属性,前者将在其容器中对齐自身,而后者将在其自身中对齐其子对象。我可能错了。。。对不起,如果我是