1

I have an application in which I would like to change the color of the Toolbar fairly often.

Right now, I am manually setting the Status Bar color and the Toolbar color (where the status bar color is a darker version of the toolbar color).

Is it possible to instead use <item name="android:windowTranslucentStatus">true</item> in my style and have my Toolbar extend behind the status bar? That way, I wouldn't have to manually create a dark color and manually set the status bar color in addition to the toolbar color. This would also allow the navigation drawer to show in front of the status bar color and behind the actual status bar (Right now the top of the navigation drawer isn't shown because the status bar is a solid color)

vanshg
  • 1,125
  • 2
  • 10
  • 19

2 Answers2

0

i think what you are looking for is this

android:fitsSystemWindows

Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol fitsSystemWindows.
Suhaib Roomy
  • 2,501
  • 1
  • 16
  • 22
0

Try this to put toolbar behind status bar:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); }

before setContentView in Activity and add to styles windowTranslucentStatus, it makes Top of a Drawer visible

mmaksitaliev
  • 126
  • 1
  • 8