BottomNavigationView на прокрутке Скрыть / показать - PullRequest
0 голосов
/ 02 октября 2018

Хорошо, я знаю, что это дубликат, но ни одно решение, которое я нашел, не сработало.Я не знаю, в чем проблема и почему она не работает.Я хотел бы, чтобы BottomNavigationView скрывался при прокрутке gridv вниз и отображался при прокрутке вверх.Может ли кто-нибудь помочь?

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

1 Ответ

0 голосов
/ 02 октября 2018

Я бы сделал это с CoordinatorLayout и 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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...