GridLayout columnSpan和rowSpan无法正常工作

时间:2017-09-07 10:42:31

标签: android android-layout android-gridlayout

这是XML文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    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"
    android:background="@drawable/background"
    tools:context="com.example.boowman.quickreminder.MainActivity">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/toolbar2">

        <GridLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:columnCount="2"
            android:paddingBottom="10dp"
            android:rowCount="2">

            <MultiAutoCompleteTextView
                android:layout_columnSpan="2"
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="1"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

            <MultiAutoCompleteTextView
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="1"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

            <MultiAutoCompleteTextView
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="2"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

            <MultiAutoCompleteTextView
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="1"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

            <MultiAutoCompleteTextView
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="1"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

            <MultiAutoCompleteTextView
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="1"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

            <MultiAutoCompleteTextView
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="1"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

            <MultiAutoCompleteTextView
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="1"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

            <MultiAutoCompleteTextView
                android:layout_columnWeight="1"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:layout_rowSpan="1"
                android:layout_rowWeight="1"
                android:background="#dee2de"
                android:text="6th"
                android:textSize="20sp"/>

        </GridLayout>
    </ScrollView>
</RelativeLayout>

当我尝试将rowSpan设置为2时,任何项目都没有发生,columnSpan到2就可以了。同时将columnSpan设置为2并将rowSpan设置为2不会影响rowSpan 为什么这不起作用以及如何使其发挥作用?

https://i.imgur.com/UESnCwS.png

在此屏幕截图中,您可以看到我第一次将rowSpan 2(第4项)放入第3项的rowSpan时取消。 https://i.imgur.com/kN37tUU.png

0 个答案:

没有答案