Android 滚动WebView时隐藏BottomAppBar

Android 滚动WebView时隐藏BottomAppBar,android,user-interface,webview,android-bottomappbar,Android,User Interface,Webview,Android Bottomappbar,我的家庭布局活动有以下代码 <?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" an

我的家庭布局活动有以下代码

<?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"
    tools:context=".MainActivity">

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />


    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/bottom_navigation"
        style="@style/Widget.MaterialComponents.BottomAppBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_gravity="bottom"
        app:backgroundTint="@android:color/white"
        app:fabCradleMargin="16dp"
        app:fabCradleRoundedCornerRadius="8dp"
        app:hideOnScroll="true"
        app:itemBackground="@color/colorPrimary"
        app:itemIconTint="@android:color/white"
        app:itemTextColor="@android:color/white"
        app:elevation="0dp"
        android:elevation="0dp"
        app:layout_scrollFlags="scroll|enterAlways"
        tools:ignore="BottomAppBar">

        <include
            android:id="@+id/nav_bar"
            layout="@layout/bottom_navigation_bar" />
    </com.google.android.material.bottomappbar.BottomAppBar>

</RelativeLayout>

我想在滚动webview时隐藏底部的应用程序栏。我当然包括了hideOnScroll并将其设置为真。不幸的是,滚动时它从不隐藏。我遗漏了什么吗?

试试这个:

webView.setOnTouchListener(new View.OnTouchListener() {
     public boolean onTouch(View v, MotionEvent event) {
       if(event.getAction() == MotionEvent.ACTION_MOVE){
         //Your Code to hide bottom bar
       }
     }
 });