Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error adding custom theme to app

I added the following theme to my app with a background color of white.But I get the following error and I'm not sure where I have gone wrong.

Error: Color types not allowed (at 'android:windowBackground' with value '#FF0000').

<style name="MyTheme" parent="@android:style/Theme.Light"> 
  <item name="android:windowBackground">#FF0000</item>
 </style>

And referenced the theme in mymanifest:

<activity
        android:name=".MyActivity"
        android:theme="@style/MyTheme" />

Any ideas or suggestions? Thanks

like image 388
Brian Var Avatar asked Mar 20 '13 13:03

Brian Var


People also ask

How do I put themes on my apps?

In the Project pane select Android, go to app > res > values > themes > themes.

How do I apply a theme to my android?

You can create a theme the same way you create styles. The difference is how you apply it: instead of applying a style with the style attribute on a view, you apply a theme with the android:theme attribute on either the <application> tag or an <activity> tag in the AndroidManifest. xml file.


1 Answers

According to the Android Styles and Themes page, you have to use a separate color resource to set the color.

(Note that the color needs to supplied as a separate resource here because the android:windowBackground attribute only supports a reference to another resource; unlike android:colorBackground, it can not be given a color literal.)

For example

<item name="android:windowBackground">@color/custom_theme_color</item>
like image 110
Sean O'Toole Avatar answered Oct 28 '22 20:10

Sean O'Toole