0

我有 3 个按钮,滚动视图包含文本和图像。我只想要图像和文本的滚动视图效果,并且我的 3 个按钮固定在滚动视图上,我该怎么做?

4

1 回答 1

0

使用FrameLayout.

下面演示了一个顶部栏的示例,其中三个按钮位于ScrollView图像上方。

FrameLayout' 按照声明的顺序渲染他们的孩子。对于下面的示例,ScrollView首先呈现的是LinearLayout 按钮栏,最后呈现的是LinearLayout 按钮栏。这会将条放置在滚动视图上方并提供所需的效果。

之所以ScrollViewLinearLayout一个孩子,是因为他们只能生一个孩子。

<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 回答