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
In the Project pane select Android, go to app > res > values > themes > themes.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With