1

テーブル レイアウトのテーブル行のボタン パーツの XML コードを次に示します。

<TableRow
    android:id="@+id/tableRow8"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >
    <Button
        android:id="@+id/buttonclear"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Clear" 
        android:layout_weight="1" android:textSize="18sp"/>
    <Button
        android:id="@+id/buttonback"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back" 
        android:layout_weight="1" android:textSize="18sp"/>
    <Button
        android:id="@+id/buttonconfirm"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Confirm" 
        android:layout_weight="1" android:textSize="18sp"/>

</TableRow>

定数 dip を入力せずに、これらのボタンを 3 つに均等に分割するにはどうすればよいでしょうか。しかし、私は体重を実験するのに運がありませんでした.

4

2 に答える 2

2

android:stretchColumnsTableLayoutの属性を使用することをお勧めします。これはゼロベースの属性であるため、この場合は値「0,1,2」を取得する必要があります。

したがって、XMLはおそらく次のようになります。

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stretchColumns="0,1,2">
    <TableRow
        android:id="@+id/tableRow8">
        <Button
            android:id="@+id/buttonclear"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Clear" 
            android:textSize="18sp"/>
        <Button
            android:id="@+id/buttonback"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Back" 
            android:textSize="18sp"/>
        <Button
            android:id="@+id/buttonconfirm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Confirm" 
            android:textSize="18sp"/>
    </TableRow>
</TableLayout>

それが役に立てば幸い。

于 2012-01-16T14:11:59.530 に答える