Is there a way to disable the dark fading effect for the background view in the Navigation Drawer View in Android?
Asked
Active
Viewed 2.0k times
4 Answers
122
You can use setScrimColor(int color)
method. As default color is used 0x99000000
. So if you don't want faded
background, set transparent
color in this method.
mDrawerLayout.setScrimColor(getResources().getColor(android.R.color.transparent));
-
4`getColor()` is deprecated. You can use: `mDrawerLayout.setScrimColor(ContextCompat.getColor(getApplicationContext(), android.R.color.transparent));` – eldivino87 Mar 16 '16 at 12:20
-
The text colour got back to normal but the icons i have used in the items in the nav drawer are still kind of faded. Why so ? – Femn Dharamshi Dec 10 '18 at 18:24
-
Android/AndroidX Remove Background color and shadow On Navigation Drawer [https://stackoverflow.com/a/58874165/4334920](https://stackoverflow.com/a/58874165/4334920) – Renish Patel Nov 15 '19 at 10:28
37
Addition to koso's answer: you can directly call the colors from Color class like this:
mDrawerLayout.setScrimColor(Color.TRANSPARENT);

C.d.
- 9,932
- 6
- 41
- 51
8
drawerLayout.setScrimColor(Color.parseColor("#99000000"));
// For dark fading effect
or
drawerLayout.setScrimColor(Color.parseColor("#33000000"));
// For light fading effect
or
drawerLayout.setScrimColor(Color.TRANSPARENT);
// For no Fading

TWiStErRob
- 44,762
- 26
- 170
- 254

Neo
- 3,546
- 1
- 24
- 31
-
This is helpful, but each line is missing a trailing closing parenthesis, and the final line should read `drawerLayout.setScrimColor(Color.TRANSPARENT);`. – Greg Brown May 16 '16 at 13:47
4
You can set a custom shadow:
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

productioncoder
- 4,225
- 2
- 39
- 65