Search code examples
androidbottomnavigationview

Bottom Navigation Bar overlaps view above it


I have following view hierarchy

<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".activity.MainActivity"
    >

    ...

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/am_bottom_navigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:background="@color/colorPrimary"
            app:itemIconTint="@drawable/bottom_navigation_colors"
            app:itemTextColor="@drawable/bottom_navigation_colors"
            app:labelVisibilityMode="unlabeled"
            app:menu="@menu/menu_bottom_navigation"
            />

        <include layout="@layout/toolbar" />

        <View
            android:id="@+id/am_fade_background"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:alpha="0.5"
            android:visibility="gone"
            android:background="@android:color/black"
            android:layerType="hardware"
            />

        <FrameLayout
            android:id="@+id/am_tracker_over_layout"
            android:visibility="gone"
            android:layout_margin="20dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            />

    </RelativeLayout>

I want for am_tracker_over_layout to be shown ahead everything else, but BottomNavigationView gets ahead. Made it transparent for clarity.

BottomNavigationView overlaps view above it

Tried googling it. Read that the last view in group is shown ahead, but it doesn't seem to be true with BottomNavigationView.

So, how can I explicitly move BottomNavigationView behind some other view?


Solution

  • It seems like you need to set bottom navigation view elevation. try to add following property in bottom navigation view tag

    android:elevation="0dp"