0

ScrollViewを作成し、固定の高さ(つまり、「250px」)を設定せずに、使用可能なスペースに拡張したいと考えています。

そのため、RelativeLayoutを作成しました。基本的な概要は次のとおりです。

<RelativeLayout>
    <LinearLayout 
        android:id="@+id/x" >
        <TextView 
            android:text="Title" ... />
    </LinearLayout>
    <ScrollView 
        android:id="@+id/y"
        android:layout_below="@id/x" />
    <LinearLayout
        android:layout_below="@id/y" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:gravity="center_horizontal|bottom" >
        <Button ...>
    </LinearLayout>
</RelativeLayout>

レイアウトの考え方は、タイトルを上に、ボタンを画面の下部近くに、ScrollViewをこれら2つの間に配置することです。

問題は、ScrollViewの定義でandroid_heightを使用する必要があるため、その高さに固定されていることです。

どうすればこれを回避できますか?

ありがとう。

4

1 に答える 1

1

このレイアウトは、外側の要素として LinearLayout を使用すると、よりシンプルになるようです。orientation="vertical"

すべての要素の layout_height を wrap_content に設定します。scrollView 以外のすべての要素の重みを 0 に設定し、scrollView の重みを 1 に設定します。

于 2010-08-24T19:20:47.843 に答える