android - BottomAppBar 和 FloatingActionButton 应用程序:layout_scrollFlags 行为
问题描述
我目前在我的布局中使用 BottomAppBar 和 FloatingActionButton 的组合(显然在 CoordinatorLayout 内部):请参阅布局:
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:backgroundTint="@color/primarycolor"
app:theme="@style/ThemeOverlay.MaterialComponents.Dark"
app:fabAlignmentMode="center"
app:layout_scrollFlags="scroll|enterAlways"
app:navigationIcon="@drawable/ic_menu_time" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
app:backgroundTint="#FFFF0000"
app:layout_anchor="@id/bar"
app:rippleColor="#FFFF8888"
app:srcCompat="@drawable/ic_fab_search" />
列表滚动的行为就像 BottomAppBar 的魅力,但我对 FloatingActionButton 有很大的问题。
正如您在下面的屏幕截图中看到的那样,BottomAppBar 完全消失了,这很棒,但对于 FAB,我无法得到相同的结果。它只是在底部移动了一点。
知道我可以从哪里开始解决这个问题吗?正确的行为是 FAB 跟随 Bar 并简单地消失
在卷轴之后:
解决方案
您应该自己隐藏 FAB。只需调用fab.hide()
并fab.show()
管理其可见性。
推荐阅读
- vue.js - 从 DOM 元素获取 Vue 数据绑定模型
- python - 如何在 Django Rest Framework 序列化程序中捕获 sql 错误?
- nullpointerexception - 为什么我使用 PDFBox 2.0.19 中的 PDField.setValue() 得到 NullPointterException?
- javascript - 让垂直滚动字幕脚本在多个选项卡中工作
- android - 使用 androidx 在 Viewpager 中进行点设计
- javascript - Ag - 使用 processCellCallback 将网格中的网格导出下拉到 excel
- python-3.x - Python将列表解析为列表列表
- azure-devops - Azure Devops 回归测试用例管理
- c# - Visual Studio 2019 中没有 GitHub 的连接选项
- python - 在 pygame -Python 上删除绘图而不覆盖以前的绘图