0

I want to set a custom theme to my android application, but unable to do so. Following is my xml snippet :

res/values/themes.xml

<?xml version="1.0" encoding="utf-8"?> <resources> <!-- the theme applied to the application or activity --> <style name="CustomActionBarTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="android:actionBarStyle">@style/MyActionBar</item> </style> <!-- ActionBar styles --> <style name="MyActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse"> <item name="android:background">#FF0000</item> </style> </resources> 

In manifest I've changed the android:theme property to :
android:theme="@style/CustomActionBarTheme"

But still, its not working for me. The theme am getting is Theme.AppCompat.Light.DarkActionBar.

3 Answers 3

2

I found the solution by modifying style.xml :

<!-- Base application theme. --> <style name="CustomAppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">#FF0000</item> </style> 
Sign up to request clarification or add additional context in comments.

1 Comment

That's because, when you're using AppCompat you define attributes without android: prefix ie. android:background, android:colorPrimary. Read this page carefully, if you want to keep your app backward compatible: Styling the Action Bar.
0

You need to create res/values/style.xml or make these changes in res/values/style.xml

themes.xml not work in android project.

And set your custom theme in your manifest in

<application ... android:theme="@style/Your_Custom_Theme_Name" > ... </application> 

2 Comments

but this way I found on developer.android.com. Plus, the one you mentioned is not working
Yes. I am extending with it.
0

Add your CustomActionBarTheme theme in res/values/style.xml and it will work.

1 Comment

but this way I found on developer.android.com. Plus, the one you mentioned is not working

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.