Ale4303
Ale4303

Reputation: 459

Elevation not working on BottomNavigationView

The elevation on my BottomNavigationView isn't woking, when I start my app all the other UI components get their specific elevation but the BottomNavigationView.

Here's the XML:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <FrameLayout
        android:id="@+id/main_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/bottom_navigation"
        android:layout_alignParentTop="true">
    </FrameLayout>

    <android.support.design.widget.BottomNavigationView
        android:elevation="8dp"
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:itemBackground="@color/white"
        app:itemIconTint="@drawable/nav_item_color_state"
        app:itemTextColor="@drawable/nav_item_color_state"
        android:layout_alignParentBottom="true"/>

</RelativeLayout>

What can I do?

Note: no color is transparent.

Upvotes: 2

Views: 2088

Answers (2)

Nikola Despotoski
Nikola Despotoski

Reputation: 50538

Shadow is drawn downwards (from the bottom of the view), you can see that android:elevation="8dp" is applied if you try to show Snackbar, you won't be able to see it.

If you want to add shadow that will be shown from the top of the BottomNavigationView you need to draw it manually.

Upvotes: 1

Alessandro Ponte
Alessandro Ponte

Reputation: 21

You should use the namespace xmlns:app="http://schemas.android.com/apk/res-auto" and use the app:elevation = "8dp" instead of android:elevation="8dp"

Upvotes: 2

Related Questions