问题描述
我只有一个Activity
,其布局内有BottomNavigationView
:
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
app:menu="@menu/menu_home_bottom_navigation"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
我的bottom_avigation
用片段更改了nav_host
FragmentContainerView
。所有这些片段都具有NestedScrollView
或RecyclerView
,并且由于app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
,我的bottom_navigation
会在scrollDown / scrollUp上自动隐藏/显示。
我看到了这个问题:Hide/Show bottomNavigationView on Scroll 。我目前正在使用 Abhishek Singh 给出的答案,但问题不在于此。
这是我的问题:想象FragA
和FragB
都有RecyclerViews
,但是FragA
的项目较少,导致所有项目都适合屏幕且不可滚动。现在,当我从FragA
切换到FragB
然后向下滚动时,bottom_navigation
会隐藏起来,并显示动画,如果按返回按钮,我将不再看到bottom_navigation
,因为FragA
无法滚动,无法通过滚动使其可见。
我还在bottom_navigation.visibility = View.Visible
FragA
事件中尝试过onResume
,但仍然无法正常工作。我认为它以某种方式将bottom_navigation
转换为底部,因此该代码无济于事。
那我该如何解决这个问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)