Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.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 如何创建每行具有不同列数的tableLayout_Android_Tablelayout_Android Tablelayout - Fatal编程技术网

Android 如何创建每行具有不同列数的tableLayout

Android 如何创建每行具有不同列数的tableLayout,android,tablelayout,android-tablelayout,Android,Tablelayout,Android Tablelayout,我使用了相对布局视图,每一行我都为2列和3列创建了新的相对视图,我尝试在一个tablelayout中创建它,但在列的情况下存在问题,我不能在同一个tablelayout中创建,一行中有2列,另一行中有3列,我如何创建它 我的代码是: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/

我使用了相对布局视图,每一行我都为2列和3列创建了新的相对视图,我尝试在一个tablelayout中创建它,但在列的情况下存在问题,我不能在同一个tablelayout中创建,一行中有2列,另一行中有3列,我如何创建它 我的代码是:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/relativeLayout1">
        <include layout="@layout/navactionbar"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Rotaract KNE"
            android:textAlignment="center"
            android:textSize="24dp"
            android:layout_centerVertical="true"
            android:textColor="@color/navheadtxt"
            android:textStyle="bold"/>
    </RelativeLayout>
    <TextView
        android:id="@+id/bodmen"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Board Of Directory"
        android:textAlignment="center"
        android:textSize="24dp"
        android:layout_below="@+id/relativeLayout1"
        android:layout_marginTop="15dp"
        android:textColor="@color/colorAccent"
        android:textStyle="bold"/>
    <RelativeLayout
        android:id="@+id/relativeLayout2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/relativeLayout1"
        android:layout_marginTop="45dp"
        android:layout_centerHorizontal="true">
        <TableLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/table1">
            <TableRow>
                <ImageButton
                    android:id="@+id/preimg"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:src="@mipmap/ic_app"
                    android:layout_marginEnd="10dp"/>
                <ImageButton
                    android:id="@+id/secimg"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_marginStart="10dp"
                    android:src="@mipmap/ic_app"/>
            </TableRow>
        </TableLayout>
    </RelativeLayout>
    <RelativeLayout
        android:id="@+id/relativeLayout3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/relativeLayout2">
        <TableLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/table2">
            <TableRow>
                <ImageButton
                    android:id="@+id/ppimg"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:src="@mipmap/ic_app"
                    android:layout_marginEnd="10dp"/>
                <ImageButton
                    android:id="@+id/tre_intimg"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:src="@mipmap/ic_app"
                    android:layout_marginStart="10dp"
                    android:layout_marginEnd="10dp"/>
                <ImageButton
                    android:id="@+id/sgtatarmimg"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:src="@mipmap/ic_app"

                    android:layout_marginStart="10dp"/>
            </TableRow>
        </TableLayout>
    </RelativeLayout>
    <RelativeLayout
        android:id="@+id/relativeLayout4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/relativeLayout3">
        <TableLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/table3">
            <TableRow>
                <ImageButton
                    android:id="@+id/clubeimg"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:src="@mipmap/ic_app"
                    android:layout_marginEnd="10dp"/>
                <ImageButton
                    android:id="@+id/communitiyimg"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:src="@mipmap/ic_app"
                    android:layout_marginStart="10dp"
                    android:layout_marginEnd="10dp"/>
                <ImageButton
                    android:id="@+id/ppdimg"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:src="@mipmap/ic_app"
                    android:layout_marginStart="10dp"/>
            </TableRow>
        </TableLayout>
    </RelativeLayout>


我不确定,但不需要使用相对布局作为外部布局,只需添加一个表布局,然后添加表行,然后您就可以按照自己的方式进行自定义。我不确定,但不需要使用相对布局作为外部布局,只需添加一个表布局,然后添加表行,然后您就可以按照自己的方式进行自定义