1

デザインに問題があります。説明させてください。ここに画像の説明を入力してください

上部にいくつかのテキスト行があるTextViewがあります。次に、ボタン、ScrollView、およびボタンのあるレイアウトがあります。ボタンの間にScrollWiewを配置したいと思います。問題は、Scrolアイテムがたくさんある場合、ケース1のようにすべてが問題ないことです。しかし、アイテムが2つしかない場合は、ケース2のように表示されます。ボタンとScrollViewが下部の必要なスペースを占有し、textViewが残りのスペースを占有するようにします。ちなみに、テキストビューのこれらの行は常に表示されるようにしたいので、テキストビューの最小スペースはこれらの行によって制限されます。

XMLだけを使ってやりたいです。

私のXML:

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

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/myText1"
        android:textColor="@color/white"
        android:textSize="28dip" />

    <TextView
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="12345"
        android:textColor="@color/white"
        android:textSize="28dip" >
    </TextView>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="0px"

    android:layout_weight="1"
    android:orientation="vertical" >

    <Button
        android:id="@+id/btn_add"

        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="1dp"
        android:gravity="left|center_vertical"
        android:text="@string/add_text" />


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="bottom"
            android:orientation="vertical" >

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="1dp"
                android:background="@color/white"
                android:gravity="left|center_vertical"
                android:paddingRight="20dp"
                android:text="1"
                android:textColor="@color/black" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="1dp"
                android:background="@color/white"
                android:gravity="left|center_vertical"
                android:paddingRight="20dp"
                android:text="2"
                android:textColor="@color/black" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="1dp"
                android:gravity="left|center_vertical"
                android:paddingRight="20dp"
                android:text="3"
                android:textColor="@color/black" />
        </LinearLayout>
    </ScrollView>

    <Button
        android:id="@+id/btn_cancel"
        android:layout_height="wrap_content"
        android:layout_marginRight="1dp"
        android:layout_weight="1"
        android:text="@string/cancel" />

</LinearLayout>

私はRelativeLayoutを使おうとしましたが、何かがうまくいかなかったと思います。同じ結果が出たからです。

4

1 に答える 1

1

スクロールビューのプロパティを次のように変更します

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="200dip">
于 2012-12-03T09:03:00.953 に答える