[英]Android how to show toolbar after hiding (by scrolling down in RecyclerView)
我有带有三个片段的BottomNavigationView 。 第一个有一个RecyclerView ,我实现了在滚动这个 RecyclerView 后隐藏工具栏,它可以工作。 当我更改片段时,我想再次显示它(actionbar) - 但 actionbar.isShowing() 返回 true 并且 actionbar.show() 不起作用。 也许有人有想法?
activity_main.xml
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
tools:context=".main.MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">
<androidx.appcompat.widget.Toolbar
android:id="@+id/mainToolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:title="@string/app_name"/>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/mainNav"
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@android:color/white"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
app:menu="@menu/user_tabs_menu" />
<FrameLayout
android:id="@+id/mainFrameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
当您更改片段时,您应该调用AppBarLayout.setExpanded(true)
您能否向我们展示一些有关如何使工具栏消失的代码?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.