Search code examples
androidcolorsandroid-actionbartoolbarstatusbar

Darken Toolbar Color for Statusbar in Android Lollipop


I have different Actionbar (Toolbar) colors in some of my activities. I get the colors from resources and there are HEX.

mToolbar.setBackground(new ColorDrawable(getResources().getColor(CharacterColors[CharID - 1])));

How i can generate a darker version of each color for status bar?

For example i want darken my Toolbar color (#34495e) to (#2a3a4b) and set it as my status bar color.


Solution

  • You would need to write a method yourself unlike standard Java as there is a Color.darker() method.

    Check this answer for a working method.