0

3 つのボタンがあり、スクロール ビューにはテキストと画像が含まれています。画像とテキストに対してのみスクロールビュー効果が必要で、3 つのボタンをスクロールビュー上に固定するにはどうすればよいですか?

4

1 に答える 1

0

を使用しFrameLayoutます。

画像付きの上に 3 つのボタンがあるトップ バーの例をScrollView以下に示します。

FrameLayoutは、宣言された順序で子をレンダリングします。以下の例では、ScrollViewが最初にレンダリングされ、LinearLayout ボタン バーが最後にレンダリングされます。これにより、スクロールビューの上にバーが配置され、目的の効果が得られます。

ScrollViewが子供として を持っている理由はLinearLayout、子供が 1 人しか持てないためです。

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>
        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:orientation="horizontal">

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"/>

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"/>

        <Button
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"/>
    </LinearLayout>
</FrameLayout>
于 2014-11-05T23:06:09.460 に答える