如何在android表格布局中合并两行

问题描述 投票:0回答:1

我想知道如何在android表格布局中合并两行。我知道android:layout_span用于合并列和什么用于合并两行的属性?

java android xml
1个回答
0
投票

TableLayout中没有rowspan属性。更好地使用LinearLayoutRelativeLayout。它简单得多。或者使用GridLayout for API Level> 13

如果您依赖TableLayout,您可以实现如下行排:

<TableLayout ...>
    <TableRow..>

        <!-- Column 1 : Rowspan 2 --> 
        <TextView .../>                      

        <!-- Column 2 : 2 Rows -->
        <TableLayout ...>
            <TableRow..>
                <TextView .../>                     
            </TableRow>
            <TableRow..>
                <TextView .../>              
            </TableRow>
        </TableLayout> 

    </TableRow>

</TableLayout>

使用LinearLayouts解决方案(便宜又简单):

<LinearLayout 
    ...
    android:orientation="horizontal">

    <!-- Column 1 -->
    <LinearLayout
        ... 
        android:orientation="vertical">

        <TextView .../>  

    </LinearLayout>

    <!-- Column 2 -->
    <LinearLayout
        ... 
        android:orientation="vertical">

        <TextView .../>  
        <TextView .../>  

    </LinearLayout>

</LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.