0

I am having a bottom navigation view and I would want to hide it by showing a dummy view on top of it. In the relative layout, I am placing the dummy view on top of the bottom navigation view. But always the bottom navigation view shows on top. Why does the bottom navigation view does not follow layout hierarchy?

 <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/bottomNavigationView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@color/white"
            android:theme="@style/BottomBar"
            android:visibility="visible"
            app:itemTextAppearanceActive="@style/BottomNavigationViewTextStyle"
            app:itemTextAppearanceInactive="@style/BottomNavigationViewTextStyle"
            app:labelVisibilityMode="labeled"
            app:menu="@menu/bottom_navigation_menu" />

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentBottom="true"
            android:background="@color/black" />

    </RelativeLayout>

I expect the View to be shown on top of the bottom navigation view(So that the bottom navigation view is invisible), but bottom navigation view always shown on top

abhishek maharajpet
  • 482
  • 1
  • 4
  • 18
  • Post a screenshot. – OhhhThatVarun Apr 12 '21 at 12:33
  • Only the bottom Navigation View is shown, not sure why the dummy view is getting hidden. If I remove the dummy view and place it outside the relative layout by adding one more parent layout, then the dummy view is being shown. – abhishek maharajpet Apr 12 '21 at 12:39
  • 1
    Be sure your dummy has higher or equal elevation to bottom navigation view. – Pawel Apr 12 '21 at 12:54
  • Thank you @Pawel. Based on the following link https://material.io/components/bottom-navigation/android#bottom-navigation-bar, the bottom navigation view has a default elevation of 8dp. Changing the elevation should fix the issue. – abhishek maharajpet Apr 12 '21 at 17:00

1 Answers1

1

Based on the following link https://material.io/components/bottom-navigation/android, the bottom navigation view has a default elevation of 8dp. Changing the elevation of dummy layout will fix the issue.

abhishek maharajpet
  • 482
  • 1
  • 4
  • 18