4

我有一个底部应用栏,带有居中的工厂和菜单。当我在列表中选择一个项目时,我想更改工厂对齐和菜单。更改效果很好,但动画显示闪烁效果。

我尝试在工厂动画结束时使用处理程序更改菜单(根据底部应用栏类为 300 毫秒),但副作用仍然存在

我的布局:

<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>

我的代码:

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))
            }
        }
    }

我期待这样的动画:https ://storage.googleapis.com/spec-host/mio-staging%2Fmio-components%2F1568406561463%2Fassets%2F1KJSld6h82fzkcafrHCDFPOITibpWxF-5%2Fbehavior-layout-primary.mp4

我有: 底栏动画

谢谢

4

0 回答 0