【问题标题】:add 5 columns table row layout in android studio在 android studio 中添加 5 列表格行布局
【发布时间】:2018-08-31 19:35:10
【问题描述】:

我在 android 中有应用程序。接口依赖于tablelayout,每一行的内容都不同。 我想在某些行中显示 5 列...怎么可能?

【问题讨论】:

    标签: android android-tablelayout


    【解决方案1】:

    每行可以有可变数量的列,这是一个示例:

    <TableLayout
            android:layout_width="wrap_content"
            android:stretchColumns="*"
            android:layout_height="wrap_content">
    
            <!-- First row has 5 columns -->
            <TableRow>
                <TextView
                    android:layout_column="1"
                    android:text="Column 1" />
    
                <TextView
                    android:layout_column="2"
                    android:text="Column 2" />
    
                <TextView
                    android:layout_column="3"
                    android:text="Column 3"/>
    
                <TextView
                    android:layout_column="4"
                    android:text="Column 4"/>
    
                <TextView
                    android:layout_column="5"
                    android:text="Column 5" />
            </TableRow>
    
            <!-- Second row has 3 columns -->
            <TableRow>
                <TextView
                    android:layout_column="1"
                    android:text="Column 1" />
    
                <TextView
                    android:layout_column="2"
                    android:text="Column 2" />
    
                <TextView
                    android:layout_column="3"
                    android:text="Column 3"/>
            </TableRow>
        </TableLayout>
    

    【讨论】:

    • 您可以将任何视图放入tablerow &lt;TableRow&gt; &lt;Button android:layout_column="1" android:text="Column 1" /&gt; &lt;EditText android:layout_column="2" android:text="Column 2" /&gt; &lt;/TableRow&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多