0

看看下面的 Button12s。它只是一个带有“GO”文本的按钮,但按钮非常宽。我希望它和文本一样宽。
如果这很重要,它会嵌套在表格中。

        <TableRow
            android:id="@+id/TableRow1_1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <CheckBox
                android:id="@+id/CheckBox25"
                android:layout_width="fill_parent"
                android:layout_height="25dp"
                android:text="@string/_3x12s" />

            <Button
                android:id="@+id/Button12s"
                android:minHeight="1dp"
                android:minWidth="1dp"
                android:onClick="starttimer"
                android:text="@string/_GO" />

图片链接(我还不能嵌入):http: //i.stack.imgur.com/nvFl7.png

4

1 回答 1

0

android:minWidth="1dp" will cause it to fill the row.

use android:layout_width="wrap_content" to make it tightly fit around the word.

A layout like this might be what you want

<TableRow
    android:id="@+id/TableRow1_1"

    android:layout_width="fill_parent"

    android:layout_height="wrap_content" >
    <LinearLayout android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:orientation="horizontal"
                  android:layout_weight="1"
                  >
        <CheckBox
                android:id="@+id/CheckBox25"
                android:layout_width="wrap_content"
                android:layout_height="25dp"
                android:text="3x12s" />
        <Button
                android:id="@+id/Button12s"
                android:layout_width="wrap_content"
                android:layout_height="25dp"
                android:paddingLeft="10dp"
                android:layout_marginLeft="10dp"
                android:paddingRight="10dp"
                android:layout_marginRight="10dp"
                android:onClick="starttimer"
                android:background="@color/grey"
                android:text="GO" />
    </LinearLayout>
    <CheckBox
            android:id="@+id/CheckBox30"
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="25dp"
            android:text="5reps" />
</TableRow>

But I would recommend making your rows bigger than the 25dp that you showed in your sample, as that is a hard button to press.

于 2013-05-03T00:57:34.763 回答