0

I have the following code on my home layout activity.

<?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>

I want to hide the bottom app bar on scrolling the webview. I have of course included the hideOnScroll and set it true. Unfortunately, it never hides on scrolling. Am I missing out something?

1 Answers1

1

Try this :

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