1

CoordinatorLayout を使用して、フローティング アクション ボタンをスナックバーの上に保持しています。これはうまく機能します。...ただし、最初のスナックバーのみです。2 番目の FAB が作成されると、最初の FAB がまだそこにある間に FAB がその下にスライドします。

アイテムを削除できる RecyclerView でこれを使用しています。アイテムが削除されると、「元に戻す」スナックバーが表示されます。したがって、いくつかのアイテムを次々に削除すると、表示されているスナックバーが新しいものに置き換えられます (これにより、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>

これは、アイテムを削除した後の様子です

ここに画像の説明を入力

...そして、別のアイテムを削除した後

ここに画像の説明を入力

4

1 に答える 1

0

スナックバーはビューの上のレイヤーであるため、これは常に発生します..スタックされたスナックバーはこのシナリオでは使用しないでください.Googleガイドラインを参照してください.. https://www.google.co.in/design/spec/components/snackbars- toasts.html#snackbars-toasts-usage

それどころか、実装は https://github.com/jenzz/Android-UndoBarのようなものにする必要があります

デザイン変更のお詫び

于 2015-10-12T11:25:16.813 に答える