0

Here's what my bottom navigation bar in XML looks like:

<android.support.design.widget.BottomNavigationView
      android:id="@+id/bottom_nav"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:background="@android:color/white"
      app:itemBackground="@color/primary"
      app:elevation="8dp"
      app:menu="@menu/main_activity_bottom_nav"/>

If I remove app:itemBackground="@color/primary", the elevation shows properly, but the moment I add that back in, it disappears.

0xCursor
  • 2,242
  • 4
  • 15
  • 33
Sree
  • 2,727
  • 3
  • 29
  • 47
  • Maybe [this post](https://stackoverflow.com/questions/40766722/how-do-i-add-elevation-shadow-to-my-bottomnavigationview-it-doesnt-come-by-d) could be helpful. – 0xCursor Jun 21 '18 at 21:44
  • I came across that and if you see my code I actually made the background white – Sree Jun 21 '18 at 23:04

1 Answers1

0

I think that the problem is not use the app:itemBackground property, but the color that you set as itemBackground.

If I change my app:itemBackground color to white, it works fine, and I can show the shadow above and bottom of the BottomNavigationView. But if I use my primary color (blue), I can see the shadow only on the bottom of my BottomNavigationView.

I think that the easiest way to solve this problem, is create your own shadow and set it above of your BottomNavigationView. It's very simple. This post describes what you have to do.

If you encounter some problems, let a comment below.

I hope that this answer can help you!!

Good luck!!

moamsi
  • 16
  • 2
  • yea, that's actually what i ended up doing, but i was hoping someone would know why setting that messes things up – Sree Jun 22 '18 at 00:22