2

I cannot remove elevation (shadow) of NavigationView for Lollipop and higher versions. I added mDrawerLayout.setScrimColor(Color.TRANSPARENT); to my DrawerLayout, but it affects on pre-Lollipop versions. I also tried to add app:elevation="0dp" and android:elevation="0dp" to my NavigationView but unsuccessful.

enter image description here

I need to get the result of android 4 on android 6.

Pavlo28
  • 1,454
  • 2
  • 16
  • 30
  • 1
    " I also tried to add app:elevation="0dp" and android:elevation="0dp" to my NavigationView but unsuccessful." - Thats becouse you have to set app:elevation="0dp" for NavigationDrawer, not NavigationView. Just for people looking for help in future, since thats quite old post :P – Alky Jan 28 '21 at 22:02

3 Answers3

6

I have found the solution:

mDrawerLayout.setDrawerElevation(0);

enter image description here

Pavlo28
  • 1,454
  • 2
  • 16
  • 30
3

Heres a solution with just xml.

<android.support.design.widget.NavigationView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:elevation="0dp"
        app:menu="@menu/navigation_menu" />
bb441db
  • 276
  • 1
  • 3
  • 11
0

Have you tried this way?

yourDrawer.setDrawerShadow(R.drawable.someDrawable, GravityCompat.START);

How to disable DrawerLayout Shadow

Community
  • 1
  • 1
xxx
  • 3,315
  • 5
  • 21
  • 40
  • 1
    Thanks for the answer. Yes, i tried it. No effect for Android 6. my `R.drawable.someDrawable` is ` `. Also the solution you have linked is from 2013, unfortunately, it doesn't work for > android 5.0. I suppose the problem is elevation. UPD: I just tried to use png image as `R.drawable.someDrawable`. Unfortunately, no effect. – Pavlo28 Aug 02 '16 at 10:19
  • The ''someDrawable' should be a PNG file like this: https://developer.android.com/samples/NavigationDrawer/res/drawable-hdpi/drawer_shadow.9.html Try to use GravityCompat.END instead of GravityCompat.START – xxx Aug 02 '16 at 10:24