Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DrawerLayout's background make dimmer

I'd like to know how to make the drawer background to be come dimmer when the drawer is open. I have a transparent Drawer Menu(listView). When the drawer is opened, and for example I have a listview also under a one Menu, the two listviews overlaps. Android has a default dimming of the screen, but I'd like it to be even darker.

Android uses this kind of format: Color.DKGRAY

Update:

public void setScrimColor (int color)
Set a color to use for the scrim that obscures primary content while a drawer is open.

Parameters
color   Color to use in 0xAARRGGBB format.


mDrawerLayout.setDrawerShadow(new ColorDrawable(0xff00DDED), GravityCompat.START);
or
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
like image 455
rahstame Avatar asked Dec 09 '22 13:12

rahstame


2 Answers

You can use setScrimColor(int color) method. As default color is used 0x99000000. If you want to use color specified in resources you can call:

setScrimColor(getResources().getColor(R.color.some_color))

like image 91
Koso Avatar answered Jan 13 '23 11:01

Koso


You will have to write a custom class that extends DrawerLayout. Then you can override some methods such as onDrawerOpen() etc.

In there you can set the background of the main layout. If you're interested in the implementation of DrawerLayout, check it on Grepcode here

like image 30
dumazy Avatar answered Jan 13 '23 10:01

dumazy