0

画面の上部に 5 つのボタンがあるナビゲーション バーを作成しようとしています。異なる画面サイズでもボタンのサイズを維持し、画面の幅に合わせて拡大したいと思います。

私が見つけた最も適切な解決策はテーブルビューです。問題は、テーブルの行を 1 つだけにして、画面の残りの部分を線形ビューで続行する方法が見つからないことです。

次の例では、EditText がナビゲーション バーの直後ではなく、画面の下部に表示されます。

何か案は?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

       <TableRow android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="1" android:id="@+id/tableRow2">
           <Button android:layout_width="0dip" android:text="1" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n1"></Button>
           <Button android:layout_width="0dip" android:text="2" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n2"></Button>
           <Button android:layout_width="0dip" android:text="3" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n3"></Button>
           <Button android:layout_width="0dip" android:text="4" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n4"></Button>
           <Button android:layout_width="0dip" android:text="5" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n5" android:layout_margin="0"></Button>
       </TableRow>
       <EditText android:id="@+id/editText1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:inputType="textPostalAddress">
           <requestFocus></requestFocus>
       </EditText>
</LinearLayout>
4

2 に答える 2

0

TableLayoutは必要ありません

追加するLinearLayout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

       <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >
           <Button android:layout_width="0dip" android:text="1" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n1"></Button>
           <Button android:layout_width="0dip" android:text="2" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n2"></Button>
           <Button android:layout_width="0dip" android:text="3" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n3"></Button>
           <Button android:layout_width="0dip" android:text="4" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n4"></Button>
           <Button android:layout_width="0dip" android:text="5" android:layout_weight="1" android:layout_height="wrap_content" android:id="@+id/n5" android:layout_margin="0"></Button>
       </LinearLayout >
       <EditText android:id="@+id/editText1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:inputType="textPostalAddress">
           <requestFocus></requestFocus>
       </EditText>
</LinearLayout>
于 2011-08-02T09:00:19.460 に答える
0

このようなタイプのレイアウトでは、相対レイアウトを使用する必要があり、画面サイズ自体を処理します。

于 2011-08-02T09:16:01.173 に答える