0

For my activity, i am setting a background color for the window as

window.decorView.setBackgroundResource(R.drawable.background_red)

Now i want the status and navigation to get a darker shade over this background. How can i get this. I tried setting the theme as

`<style name="Theme.OnArrival.AccessControl" parent="Theme.OnArrival.Light">
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>

    </style>`

but it doesnt seem to be working for navigation bar. Whats the right way to do it

png
  • 4,368
  • 7
  • 69
  • 118

1 Answers1

0

To programmatically set status bar color use below code:

    Window window = activity.getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(ContextCompat.getColor(activity,R.color.statusbar_color));

Or set colorPrimaryDark in your Theme.

Refer here for more details.

Gokul Nath KP
  • 15,485
  • 24
  • 88
  • 126
  • i just need a shade over the window color. I dont know exact color for status bar / navigation bar – png Aug 15 '18 at 19:00