Is there any way to make table columns equal to a fraction of the total width?

后端 未结 1 1636
情深已故
情深已故 2021-02-04 18:01

So far in my learning I have only come across spreading column sizes equally, giving one/two a higher priority to take as much space as they need, or setting the size of a colum

相关标签:
1条回答
  • 2021-02-04 18:43

    You can do this by using android:layout_span

    Here is an example :

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:stretchColumns="*">
    
        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TextView
                android:background="#aa0000"
                android:text="1/6"
                android:gravity="center_horizontal"/>
            <TextView
                android:background="#00aa00"
                android:text="3/6"
                android:gravity="center_horizontal" 
                android:layout_span="3"/>
            <TextView
                android:background="#0000aa"
                android:text="2/6"
                android:gravity="center_horizontal"
                android:layout_span="2"/>
            </TableRow>
    </TableLayout>
    
    0 讨论(0)
提交回复
热议问题