I wanted to implement app:layout_behavior dependency. After I've implemented it, my fabCradle
options don't work. I don't know why I have this problem. I've tried to do this with scrolladapter
, but it's more relevant to use app:layout_behavior.
Activity_main.xml
<?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"
tools:context=".MainActivity">
<androidx.fragment.app.FragmentContainerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@ id/fragment_container"/>
<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:fabCradleMargin="10dp"
app:fabCradleRoundedCornerRadius="10dp"
app:fabCradleVerticalOffset="5dp"
>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@ id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="16dp"
android:background="@drawable/transparent_background"
app:menu="@menu/nav_menu"/>
</com.google.android.material.bottomappbar.BottomAppBar>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@ id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/essa"
android:src="@drawable/ic_baseline_add_24"
app:layout_anchor="@ id/bottomAppBar"
app:layout_anchorGravity="top|center"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
CodePudding user response:
delete app:layout_behavior dependency
and just add app:hideOnScroll="true"