【发布时间】:2018-11-04 00:03:47
【问题描述】:
我目前在我的布局中使用了 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 并简单地消失
滚动之后:
【问题讨论】:
-
后台是
RecyclerView还是ListView? -
我使用了ListView的这个实现:stackoverflow.com/a/40885073/327402
-
您找到解决方案了吗? @Yupi
标签: android floating-action-button coordinator-layout android-bottomappbar