0

我的 xml 文件:

   <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/layout_white"
    android:fitsSystemWindows="true">

    <androidx.constraintlayout.motion.widget.MotionLayout
        android:id="@+id/motion_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layoutDescription="@xml/scene_header"
        app:layout_scrollFlags="scroll|enterAlways|snap|exitUntilCollapsed">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recyclerView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <include
            android:id="@+id/plantRecyclerView"
            layout="@layout/plant_rv_main"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:clipToPadding="false"
            app:layout_constraintTop_toBottomOf="@id/recyclerView" />

    </androidx.constraintlayout.motion.widget.MotionLayout>

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toLeftOf="parent">

    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottom_appbar"
        style="@style/Widget.MaterialComponents.BottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:fabAlignmentMode="center"
        app:fabAnimationMode="scale"
        app:fabCradleRoundedCornerRadius="50dp"
        app:navigationIcon="@drawable/ic_menu_black_24dp" />

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/addPlantFab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="@{() -> addPlantClick.onAddPlantClick()}"
        android:src="@drawable/add_plant"
        app:fabSize="normal"
        app:layout_anchor="@id/bottom_appbar"/>
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

使用此 xml,当我通过单击主页按钮暂停应用程序并再次恢复应用程序时,FloatingActionButton 会消失。但是,当 MotionLayout 过程完成时,FloatingActionButton 将再次可见。

完成意味着进程达到0.0或1.0

另外,我认为问题可能出在应用程序主题上。所以,这是我在 styles.xml 中的应用程序主题:

<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar.Bridge">

我使用 Bridge 是因为我在开发阶段的中间更改了应用程序主题。我不知道为什么会出现这种行为。有没有人面临这样的情况?我的错误是什么?

谢谢您的回答...

4

1 回答 1

0

它与应用程序主题有关。有关更多信息,请评论此答案。

于 2020-12-03T04:39:29.850 回答