如果 android:animateLayoutChanges 在根布局上为 true,则 Snackbar 会闪烁

ard*_*evd 6 android

如果android:animateLayoutChanges设置为true. Snackbar 将在整个动画过程中反复闪烁。android:animateLayoutChanges从布局中删除参数解决了这个问题,但现在我无法享受它带来的好处。如果我android:animateLayoutChanges在子视图而不是根视图上使用,它也可以工作。

这是一个已知问题吗?有办法解决吗?

这是一个示例布局,如果显示小吃店,它将演示该问题。

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true">

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:backgroundTint="@color/colorPrimary"
        app:fabAlignmentMode="end"
        app:fabCradleMargin="4dp"
        app:fabCradleRoundedCornerRadius="16dp"
        app:fabCradleVerticalOffset="4dp"
        app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
        app:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:backgroundTint="@color/colorAccent"
        app:layout_anchor="@id/bottomAppBar"
        app:srcCompat="@drawable/ic_add"
        app:tint="@color/colorWhite" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

Tom*_*tel 3

看起来像一个开放的错误。看这里