Search code examples
javaandroid-studiobottomnavigationview

hiding bottom navigation view when open slide menu


I have a bottom navigation view in my project with 2 fragments and every fragment has a slide menu (navigation view) and I want to hide the bottom navigation view when any of my menus is showing,can someone give me an example how to do that?and if there is a similar question, I would be glad if you would show me it, because I have not found anything similar


Solution

  • if your layout like this :

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.drawerlayout.widget.DrawerLayout
    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:id="@+id/drawer_layout"
    tools:openDrawer="start"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_height="?attr/actionBarSize">
    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:menu="@menu/buttom_nav_menu"/>
    </RelativeLayout>
    
    <com.google.android.material.navigation.NavigationView
        android:layout_gravity="start"
        app:menu="@menu/menu"
        android:layout_width="330dp"
        android:layout_height="match_parent"/>
    
    </androidx.drawerlayout.widget.DrawerLayout>
    

    you will not need to hide the bottom navigation view because the slide menu is in front of it