1

次のビュー ウィジェットを使用してビューを整理しようとしています -

  • TextView (画面の幅を埋める必要があり、特定の高さがあります)
  • Draw() を使用して描画されたカスタム ビュー (幅を埋め、上記のテキストビューの後に開始し、画面を埋めます)

ボード ゲームを作成しようとしているため、カスタム ビューが描画されます。

私の問題は、これに使用するのに最適なレイアウトは何ですか?

TableLayout を使用して、これら 2 つのビューをそれぞれ 1 つの列にすることはできますか? これでうまくいくと思いましたが、カスタムビューに使用するレイアウトは、描画しているテーブル行が画面を埋め尽くしても、画面を埋めません。

私は自分自身を適切に説明できたことを願っています。どんなポインタでも大歓迎です。

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/root_layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/tl_question"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:shrinkColumns="1"
            android:stretchColumns="2">

            <TableRow>
                <TextView
                    android:id="@+id/question"
                    android:layout_width="wrap_content"
                    android:textSize="30sp"
                    android:textColor="#ffFFFFFF"   
                    android:layout_gravity="center_vertical"
                    android:paddingBottom="9dip"
                    android:layout_marginLeft="3dip"
                    android:layout_marginRight="2dip"/>
            </TableRow>

            <TableRow>
                <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center_vertical" >
                    <com.ac.gui.CustomView
                        android:id="@+id/custom_board"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:keepScreenOn="true" />
                </LinearLayout>
            </TableRow>
        </TableLayout>

</RelativeLayout>
4

1 に答える 1

0

これを使ってみてください

<?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


            <TextView
                android:id="@+id/question"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:textSize="30sp"
                android:text="ASDFASDF"
                android:textColor="#ffFFFFFF"   
                android:layout_gravity="center_vertical"
                android:paddingBottom="9dip"
                android:layout_marginLeft="3dip"
                android:layout_marginRight="2dip"/>

           <com.ac.gui.CustomView

            android:layout_below="@+id/question"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />

</RelativeLayout>

あなたの代わりに別のレイアウトをテストしましたが、正常に動作します。それはあなたのものでもうまくいくはずです。

RelativeLayout を使用すると、アイテムを相互に相対的に配置できます。カスタムビューの属性「layout_below」に気付くでしょう。ここで、配置するビューの ID を指定します。

于 2011-06-10T00:29:15.060 に答える