1

テーブルレイアウトをフォーマットしようとしていますが、うまく機能していないようです。できるだけ間隔を空けて配置する必要がある4つの列があります。私は本当に同じ幅の 3 つの列を持ち、最後の列が残りのスペースを取ることを考えていました。最後の列は 2 行以上にまたがっても問題ありませんが、最初の 3 列は 1 行にする必要があり、切り詰めないでください。これが私のコードです

 <TableLayout android:id="@+id/tlMylayout" android:layout_width="fill_parent" android:layout_height="wrap_content" 
         android:stretchColumns="*"  android:shrinkColumns="*" >
        <TableRow android:layout_width="fill_parent" android:layout_height="wrap_content">

            <TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/showtext_style" android:text="col1"  />            
            <TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/showtext_style" android:text="col2"  />
            <TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/showtext_style" android:text="col3"  />            
            <TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/showtext_style" android:text="lastCol"  />
        </TableRow>
        <TableRow  android:layout_width="fill_parent" android:layout_height="wrap_content">

            <TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="2011-01-01 14:59"  />          
             <TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:text="50"  />
            <TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:text="0.57"  />           
            <TextView android:gravity="center" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="this is the last one and can be very long string if I want it to be"  />

        </TableRow>


    </TableLayout>
4

1 に答える 1