0

Before my app was with android:targetSdkVersion="14" but i decide to make it a little more modern and update it to android:targetSdkVersion="22". However now i have a little problem, the color of the top status bar during the launch phase is now gray (like on the picture) and i would prefer to have it black (like it's was before).

enter image description here

Any idea what i need to do to have my status bar black again during the launch phase ?

NOTE

I would like to change the color of the statusbar via the styles.xml. actually i try to add

<item name="android:colorPrimaryDark">@android:color/black</item>

or

<item name="android:statusBarColor">@android:color/black</item>

didn't help! this question is not a duplicate of other because i can set the StatusBar color to be black without any problem after the app is launched or fully loaded. I need to setup the black background for the statusbar during the launching phase, i mean when user click on the icon of the app their is something like a launch screen (with a define to be black via <item name="android:windowBackground">@android:color/black</item>) but the statusbar color of this launch sreen is gray (only if android:targetSdkVersion="22")

zeus
  • 12,173
  • 9
  • 63
  • 184

3 Answers3

2

The Easiest Way is :got to res -> value -> styles and add this

1: Add this in your color xml file

<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#000000</color>
<color name="colorAccent">#FF4081</color>
</resources>

2:Add this in your styles.xml file

  <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

Note:

  1. colorprimary is for Actionbar
  2. colorPrimaryDark is for Statusbar
  3. your can change these colors and u could get ur required result .

OUTPUT :

enter image description here

hope answerd the question if its useful then vote up

Abubakar
  • 374
  • 3
  • 16
1

try this

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(ContextCompat.getColor(activity, R.color.background););
}
jmarkstar
  • 1,335
  • 14
  • 21
0

try this:

  // Change color of action bar
        ActionBar bar = getActionBar();
        bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#0099CC")));
Emanuel Graf
  • 756
  • 17
  • 37