4

I have a bottom app bar with centered fab and menu. I want to change fab alignment and menu when I selecting an item in my list. The changes work great but the animation show blinking effects.

I tried to use an handler to change menu when fab animation is ended (300ms according to the bottom app bar class) but the side effect remains

My layout:

<androidx.coordinatorlayout.widget.CoordinatorLayout
    ...>

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        ...>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/home_expenseList"
            .../>

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>


    <com.google.android.material.bottomappbar.BottomAppBar
        app:layout_dodgeInsetEdges="bottom"
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:hideOnScroll="true"
        app:navigationIcon="@drawable/ic_menu"
        app:layout_scrollFlags="scroll|enterAlways"/>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/appBar_fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_add"
        app:tint="@null"
        app:layout_anchor="@id/appBar" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

My code :

override fun onSelectionModeChange(isActive: Boolean) {
        selectionIsActive = isActive
        when (isActive) {
            true -> {
                appBar.navigationIcon = null
                appBar.replaceMenu(R.menu.bottom_app_bar_selection_menu)
                appBar.fabAlignmentMode = BottomAppBar.FAB_ALIGNMENT_MODE_END
                appBar_fab.setImageDrawable(getDrawable(R.drawable.ic_close))
            }
            false -> {
                appBar.navigationIcon = getDrawable(R.drawable.ic_menu)
                appBar.replaceMenu(R.menu.bottom_app_bar_menu)
                appBar.fabAlignmentMode = BottomAppBar.FAB_ALIGNMENT_MODE_CENTER
                appBar_fab.setImageDrawable(getDrawable(R.drawable.ic_add))
            }
        }
    }

I expected an animation like this : https://storage.googleapis.com/spec-host/mio-staging%2Fmio-components%2F1568406561463%2Fassets%2F1KJSld6h82fzkcafrHCDFPOITibpWxF-5%2Fbehavior-layout-primary.mp4

I have : bottombar animation

Thanks

0 Answers0