Read More

Change drawers color and behavior

In this blog, we will learn about how we can change drawers color and behavior.

We all have seen the beauty of drawer layout and its usefulness as per our need while developing our Android applications.

But what many of us don’t know is the full capability of drawer layout.

In this blog, we will increase our knowledge about the drawer layout.

Firstly, let’s just start with changing the scrim color to our need. For those who are wondering what exactly the scrim color is, let me explain:

Do you notice, when we open the drawer, the screen on the right side goes dark, this is called scrim.

For changing this you just need to add a single line in your java code.

In the above code, you can replace RED with your own color of choice and also, if you don’t find the color already defined in the COLOR class, then you can use the hex value of your color as a string like in the example below :

Now we will try to change the behavior of drawer layout by scrolling our whole background with the drawer.

For this, all you need to do is override onDrawerSlide function of your ActionBarDrawerToggle.

and use as per your case.

Thast’s all.

For what I needed, I just had to override the onDrawerSlide function.
You can also explore other functions of the parent class as per your use case. Some of which might be useful are :

  1. onDrawerOpened
  2. onDrawerClosed
  3. onDrawerStateChanged

 

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close