How Can I set color for status bar in android?
I've tried both in styles.xml and in .java file.
If I try following code in .java class
if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.LOLLIPOP) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().setStatusBarColor(getResources().getColor(Color.DKGRAY));
}
I'm getting as exception called : -ResourceNotFoundException
04-01 18:55:21.616: E/AndroidRuntime(2169): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.cz/com.myapp.casenotez.updateCase}: android.content.res.Resources$NotFoundException: Resource ID #0xff444444
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.app.ActivityThread.-wrap11(ActivityThread.java)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.os.Handler.dispatchMessage(Handler.java:102)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.os.Looper.loop(Looper.java:148)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.app.ActivityThread.main(ActivityThread.java:5417)
04-01 18:55:21.616: E/AndroidRuntime(2169): at java.lang.reflect.Method.invoke(Native Method)
04-01 18:55:21.616: E/AndroidRuntime(2169): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-01 18:55:21.616: E/AndroidRuntime(2169): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-01 18:55:21.616: E/AndroidRuntime(2169): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xff444444
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.content.res.Resources.getValue(Resources.java:1351)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.content.res.Resources.getColor(Resources.java:963)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.content.res.Resources.getColor(Resources.java:936)
04-01 18:55:21.616: E/AndroidRuntime(2169): at com.myapp.cz.updateCase.onCreate(updateCase.java:112)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.app.Activity.performCreate(Activity.java:6237)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
04-01 18:55:21.616: E/AndroidRuntime(2169): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
04-01 18:55:21.616: E/AndroidRuntime(2169): ... 9 more
And I also tried by adding styles in styles.xml:-
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#630</item>
<item name="android:titleTextStyle"> @style/MyActionBarTitle</item>
</style>
<style name="MyActionBarTitle" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/Blue</item>
</style>