Как скрывать ActionBar при скроллинге

как я могу при скролле приложения скрывать ActionBar?

layout/toolbar.xml `

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/yellow">

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/app_name"
    android:fontFamily="@font/main_nameapp"
    android:textSize="30dp"
    android:textColor="@color/main"
    android:layout_centerInParent="true"
    android:gravity="center"/>
</RelativeLayout>`

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="@color/main_background"
tools:context=".MainActivity">

<include layout="@layout/toolbar"/>


<FrameLayout
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="?android:attr/actionBarSize"
    android:layout_above="@id/bottom_navigation"/>

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:labelVisibilityMode="labeled"
    android:layout_alignParentBottom="true"
    android:background="@color/yellow"

    app:itemIconTint="@color/bottom_navigation_color_icons"
    app:itemTextColor="@color/bottom_navigation_color_icons"
    app:menu="@menu/bottom_navigation"/>
</RelativeLayout>

Ответы (0 шт):