I am operating with the compatibility library v7.
I am just trying to set the color of my actionbar (for Android 2.1 and above - though I run Android 4.4.2) to a solid color.
However the color does not change. It remains the same.
I have also tried creating a solid drawable with the color but that also does not change.
Finally I tested if I could change the backgroudn of my layout and I could - it must be something about the actionbar background which I'm not getting.
Here is the code:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">#0000ff</item>
</style>
</resources>
You can use:
use
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#808080")));
inActivity extends SherlockActivity
or the color as your wish :)This seems to work for me. Try to use a resource instead of a raw value.
use the following code
getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg_color.xml));
actionbar_bg_color.xml
hope this help you
I solved it by:
I don't know why I couldnt get the result I wanted within themes.xml.
If anyone has an answer I'd be grateful