6

レイアウト要素の配置に問題があります。TableLayoutのオートコンプリートと、TableRowを画面の幅よりも大きく拡大した後のボタン。誰もが理由を知っていますか?以下は私のXMLコードと問題の写真です。

前もって感謝します!!

<?xml version="1.0" encoding="utf-8"?>

<TableRow android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <AutoCompleteTextView android:id="@+id/installation"
        android:textSize="14sp" android:completionThreshold="3" />
</TableRow>
<TableRow android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <Button android:id="@+id/btn_find" android:text="@string/btn_find"></Button>
</TableRow>
<TableRow android:layout_width="fill_parent"
    android:layout_height="wrap_content">
    <TextView android:id="@+id/error" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:paddingTop="20px"
        android:textColor="#FF0000" />
</TableRow>

UIの画像

4

2 に答える 2

39

テーブルレイアウトが必要な場合は、layout_weightオプションを使用します。以下のコードを参照してください。

        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:padding="6sp" android:id="@+id/detailsLayout">
            <TableRow
                android:layout_width="wrap_content"
                android:id="@+id/TableRow03"
                android:layout_height="wrap_content">
                <TextView
                    android:id="@+id/TextView06"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:text="Detail 1"></TextView>
                <TextView
                    android:text="@string/empty_value"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    android:id="@+id/sessionAudience"
                    android:layout_weight="1"></TextView>
            </TableRow>
         </TableLayout>
于 2011-06-18T12:43:45.770 に答える
5

デフォルトでは、のウィジェットにはTableRowがありますandroid:layout_width="wrap_content"。これは、画面のサイズに制限されません。つまり、wrap_content「コンテンツを折り返す」ではなく、「コンテンツを折り返すが、気にしない場合は画面の端から外れないでください」という意味です。

この場合、テーブルがないため、TableLayoutとのセットを使用する必要はありません。TableRows

したがって、1つのアプローチは、aを使用し、andRelativeLayoutAutoCompleteTextView使用することです。これにより、画面全体にサイズを設定できるの外縁に固定されます。android:layout_alignParentLeft="true"android:layout_alignParentRight="true"RelativeLayoutandroid:layout_width=fill_parent

于 2010-06-01T21:01:02.010 に答える