0

Ok I know this is duplicate, but no solution that I found didn't work. I don't know what the problem is and why it doesn't work. I would like the BottomNavigationView to hide when scrolling the gridv down and show up when scrolling up. Could anyone help?

<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=".layout.HomeActivity">

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <GridView
            android:id="@+id/gridLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:numColumns="2"
            android:scrollbars="none" />

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:layout_alignParentBottom="true"
        app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
        android:id="@+id/bottom_menu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:itemIconTint="@drawable/clicl_menu"
        app:itemTextColor="@drawable/clicl_menu"
        app:menu="@menu/bottom_menu"/>

</RelativeLayout>
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Papa Smerf
  • 31
  • 7

1 Answers1

0

I'd do that with CoordinatorLayout and app:layout_scrollFlags:

<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=".layout.HomeActivity">

    <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <GridView
            android:id="@+id/gridLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:numColumns="2"
            android:scrollbars="none" />

    </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:layout_alignParentBottom="true"
        android:id="@+id/bottom_menu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|enterAlways"
        app:itemIconTint="@drawable/clicl_menu"
        app:itemTextColor="@drawable/clicl_menu"
        app:menu="@menu/bottom_menu"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
ʍѳђઽ૯ท
  • 16,646
  • 7
  • 53
  • 108
  • Still nothing. the BottomNavigationView doesn't hide. – Papa Smerf Oct 02 '18 at 12:05
  • I guess you'll need to add `AppbarLayout` and `app:layout_behavior="@string/appbar_scrolling_view_behavior` to your content (`NestedScrollView - refresh anything in there`) in order to hide like that. – ʍѳђઽ૯ท Oct 02 '18 at 12:06