0

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

<?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 并将其设置为 true。不幸的是,它从不隐藏在滚动中。我错过了什么吗?

4

1 回答 1

1

尝试这个 :

webView.setOnTouchListener(new View.OnTouchListener() {
     public boolean onTouch(View v, MotionEvent event) {
       if(event.getAction() == MotionEvent.ACTION_MOVE){
         //Your Code to hide bottom bar
       }
     }
 });
于 2019-09-20T13:06:53.613 回答