有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在水平标签滚动上制作固定横幅?

我有这样的布局,用户可以垂直和水平滚动。它也有标签和横幅

If the user scrolls vertically, the banner collapses. But if the user scroll horizontally between tabs, I want the banner on a fixed position or is steady.

    <安卓.support.design.widget.CoordinatorLayout
        安卓:layout_width="match_parent"
        安卓:layout_height="match_parent">

        <安卓.support.design.widget.AppBarLayout
            安卓:id="@+id/appbar"
            安卓:layout_width="match_parent"
            安卓:layout_height="wrap_content"
            安卓:fitsSystemWindows="true"
            安卓:orientation="vertical"
            安卓:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <安卓.support.design.widget.CollapsingToolbarLayout
                安卓:layout_width="match_parent"
                安卓:layout_height="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">

                <ImageView
                    安卓:id="@+id/campaign_banner"
                    安卓:layout_width="match_parent"
                    安卓:layout_height="wrap_content"
                    安卓:visibility="gone" />

                <安卓.support.v7.widget.Toolbar
                    安卓:layout_width="match_parent"
                    安卓:layout_height="0dp"
                    app:layout_collapseMode="pin" />

            </安卓.support.design.widget.CollapsingToolbarLayout>

        </安卓.support.design.widget.AppBarLayout>

    </安卓.support.design.widget.CoordinatorLayout>

共 (1) 个答案

  1. # 1 楼答案

    当用户在下面的代码中以编程方式切换选项卡调用时,也使用app:layout_scrollFlags="pin"

    appBarLayout.setExpanded(true);