[英]Not able to hide toolbar on scrolling Fragment layout
我的 MainActivity 布局帶有帶有 TabLayout 和 ViewPager 的 AppBarLayout。 我無法在添加到我的視圖尋呼機的滾動片段布局上隱藏工具欄。 但是我可以隱藏在 AppBarLayout 上滾動的工具欄。
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:windowBackground">
<com.google.android.material.appbar.AppBarLayout
android:background="?android:windowBackground"
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/toolbar" />
<com.google.android.material.tabs.TabLayout
android:background="?android:windowBackground"
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabIndicatorColor="?colorAccent"
app:tabIndicatorFullWidth="false"
app:tabIndicatorHeight="3dp"
app:tabMode="scrollable"
app:tabBackground="?android:windowBackground"
app:tabSelectedTextColor="?colorAccent"
app:tabTextAppearance="@style/TabTextAppearance.Timber" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
您需要將此行添加到AppBarLayout
: app:layout_scrollFlags="scroll|exitUntilCollapsed"
並從Toolbar
布局中刪除app:layout_scrollFlags
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.