[英]Floating Action Button diasappears under SECOND Snackbar
我正在使用CoordinatorLayout將浮動操作按鈕保持在Snackbar上方,效果很好。 ...但僅限於第一個Snackbar。 創建第二個時,第一個仍在其中,而FAB則在其下方滑動。
我在RecyclerView中使用它,可以在其中刪除項目。 刪除項目后,將出現“撤消”小吃欄。 因此,當您一個接一個地刪除某些項目時,可見的Snackbar被一個新的替換(這會導致FAB行為)
您是否知道將FAB保持在新的小吃店之上的解決方案?
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/tools"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/background_grey"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:elevation="6dp"
android:src="@drawable/ic_add_white_36dp"
app:borderWidth="0dp"
app:fabSize="normal"
app:pressedTranslationZ="10dp"
app:rippleColor="@color/abc_primary_text_material_dark" />
</android.support.design.widget.CoordinatorLayout>
這是我刪除項目后的樣子
...然后刪除其他項目
這將始終發生,因為快餐欄是視圖上方的一層。在這種情況下,不應使用堆疊的快餐欄。請參見google gidelines。https ://www.google.co.in/design/spec/components/snackbars- toasts.html#小吃店,敬酒使用率
相反,您的實現應類似於https://github.com/jenzz/Android-UndoBar
更改設計的歉意
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.