0

I learned how to color an Android activity status bar thanks to this solution: How to change status bar color to match app in Lollipop? [Android]

However it doesn't say how to make this for the entire app (all activities). i don't want to duplicate those 4 lines of code into each Activity, and if I make a Java class for Utils, I can't reach my colors by using R.color.blue or getResources(....).

Is there a way to do this through the Manifest, perhaps? Or any other way?

Thank you!

Community
  • 1
  • 1
mac-man
  • 41
  • 1
  • 11
  • Did you read the second answer in the link you posted regarding styles? – zgc7009 Aug 10 '15 at 15:33
  • You dont have to add all of those lines, check out this link http://stackoverflow.com/questions/11579635/common-header-in-different-activities-using-baseactivity-in-android – Arlind Hajredinaj Aug 10 '15 at 15:34

1 Answers1

0

You should create your own style in values/styles.xml. Then make your own theme with such parameters. Loock code below

<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@color/color_primary</item>
    <item name="colorPrimaryDark">@color/color_secondary</item>
    <item name="colorAccent">@color/color_accent</item>
    <item name="android:statusBarColor">@color/color_primary</item><!--this is what you need-->
</style>

Or just use method (for Lolipop):

public abstract void setStatusBarColor (int color)
Stopfan
  • 1,649
  • 15
  • 22