我有这样的布局,其中用户可以垂直和水平滚动。它还有选项卡和横幅。
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.
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/campaign_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
最佳答案
当用户按照以下代码以编程方式切换选项卡调用时,也使用 app:layout_scrollFlags="pin"
appBarLayout.setExpanded(true);
关于java - 如何在水平选项卡滚动时制作固定横幅?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58907075/