title: How to hide bottom nav bar in fragment
body: <p>I have bottom nav bar define in the Main activity. I have three fragments linked with BottomNavigation bar in fragments I have recycler view so I want to hide BottomNavigation  bar when RecyclerView scrolls down and shows when RecyclerView scrolls up.
  My problem is how can I access BottomNavigation bar in fragments because it is defined in MainActivity.</p>
  
  <p>This is my code:</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.design.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=".MainActivity"&gt;
  
  &lt;android.support.design.widget.AppBarLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:theme="@style/AppTheme.AppBarOverlay"
      app:elevation="0dp"
      android:background="@color/colorPrimary"
      android:paddingBottom="7dp"
      android:fitsSystemWindows="true"&gt;
  
  
      &lt;android.support.v7.widget.Toolbar
          android:id="@+id/toolbar"
          android:layout_width="match_parent"
          android:layout_height="?attr/actionBarSize"
          android:background="?attr/colorPrimary"
          app:popupTheme="@style/AppTheme.PopupOverlay"
          app:layout_scrollFlags="scroll|enterAlways|snap"&gt;
  
          &lt;Spinner
              android:layout_width="110dp"
              android:layout_height="50dp"
              android:id="@+id/chooseLocation"
              app:backgroundTint="@android:color/white"/&gt;
  
      &lt;/android.support.v7.widget.Toolbar&gt;
  
      &lt;EditText
          android:layout_width="match_parent"
          android:layout_height="40dp"
          android:layout_marginLeft="16dp"
          android:layout_marginRight="16dp"
          android:id="@+id/search"
          android:paddingTop="6dp"
          android:paddingBottom="6dp"
          android:paddingRight="6dp"
          android:paddingLeft="12dp"
          android:hint="Search here"
          android:textColorHint="#9e9e9e"
          android:textColor="#000"
          tools:ignore="HardcodedText"
          android:background="@drawable/search_edit_text"
          android:paddingEnd="6dp"
          android:paddingStart="12dp"/&gt;
  
  &lt;/android.support.design.widget.AppBarLayout&gt;
  
  &lt;include layout="@layout/content_main" /&gt;
  
  &lt;android.support.design.widget.BottomNavigationView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/bottomBar"
      android:layout_gravity="bottom"
      app:menu="@menu/bottom_menu"
      android:background="#fff"
      app:itemIconTint="@drawable/nav_check"
      app:itemTextColor="@drawable/nav_check"/&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p><strong>fragment_home.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".Tab1Fragment"
  android:background="#fff"&gt;
  
  &lt;android.support.v7.widget.RecyclerView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:id="@+id/purchasedBook"/&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This is how my fragments are defined as there is no bottom nav bar in any fragments so how can I access bottom nav bar in fragments.</p>
  
  <p>Someone, please let me know any help would be appreciated.</p>
  
  <p><strong>THANKS</strong></p>