[英]How to hide FloatingActionButton which is anchored to BottomAppBar when the is hidden on scroll
[英]FloatingActionButton, which is anchored to BottomAppBar, disappears when the application is resumed
我的 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 是因為我在開發階段的中間更改了應用程序主題。 我不知道為什么會出現這種行為。 有沒有人面臨這樣的情況? 我的錯誤是什么?
謝謝您的回答...
它與應用程序主題有關。 有關更多信息,請評論此答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.