0

スクロールビューと固定ボトムバーを備えたレイアウトを実現したいと考えています。ボトムバーの高さは固定されており、スクロールビューは画面の残りの高さを取る必要がありますが、コンテンツの高さに関係なく成長することはありません (コンテンツをスクロールする必要があるため)。

たくさんのレイアウトの組み合わせを試しましたが、正しい組み合わせが見つかりません。

LinearLayout と layout_weight トリックを使用する場合、問題は同じです。

以下の例では、linearlayout の android:minHeight="600dp" を 300dp に変更すると、問題なく動作します。この例では、スクロールビューの高さが非常に大きくなるのはなぜですか?

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="2"
android:background="#fff"
android:columnCount="1"
android:orientation="vertical">
<ScrollView
    android:id="@+id/zoneContent"
    android:background="#00f"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="fill_horizontal"
    android:fillViewport="true">
    <LinearLayout
        android:background="#f00"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:minHeight="600dp" />
</ScrollView>
<GridLayout
    android:layout_height="70dp"
    android:layout_width="240dp"
    android:layout_gravity="center_horizontal|fill_vertical"
    android:background="#0f0"
    android:rowCount="1"
    android:layout_column="0"
    android:columnCount="5"
    android:layout_row="1" />
</GridLayout>
4

2 に答える 2

0

これはトリックを行うようです

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:orientation="vertical">
<ScrollView
    android:id="@+id/zoneContent"
    android:background="#00f"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:layout_gravity="fill_horizontal"
    android:fillViewport="true">
    <LinearLayout
        android:background="#f00"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:minHeight="300dp" />
</ScrollView>
<GridLayout
    android:layout_height="70dp"
    android:layout_width="240dp"
    android:layout_gravity="center_horizontal|fill_vertical"
    android:background="#0f0"
    android:rowCount="1"
    android:layout_column="0"
    android:columnCount="5"
    android:layout_row="1" />
</LinearLayout>
于 2013-03-01T10:38:36.813 に答える
0

GridLayout の代わりに LinearLayout を親レイアウトとして取得し、レイアウトの重みを修正します。

于 2013-03-01T10:51:05.800 に答える