Android : Android change status bar color dynamically

on Sunday, March 8, 2015


I'm changing the color of my Toolbar dynamically and I was wondering if I can change the color of the status bar dynamically as well to match the Toolbar. I know this can be done using:



Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor({Color});


However, what I'm looking for is to get {Color} dynamically based on the Toolbar color via a calculation/conversion instead of knowing what the hex code is for the darker version of the color.


I read the style guide and it states that the primary color (toolbar) should be the 500 color and the primary dark color (status bar) should be the 700 version. I tried converting a few of the different colors to decimal and unless I'm missing something I couldn't find a correlation between the different 500 vs 700 colors. Any help would be appreciated.


0 comments:

Post a Comment