我将以下主题添加到我的应用程序,背景颜色为白色.但我得到以下错误,我不知道我哪里出错了.
错误:不允许颜色类型(在’android:windowBackground’,值为’#FF0000′).
<style name="MyTheme" parent="@android:style/Theme.Light"> <item name="android:windowBackground">#FF0000</item> </style>
并在mymanifest中引用了主题:
<activity android:name=".MyActivity" android:theme="@style/MyTheme" />
有什么想法或建议吗?谢谢
解决方法
根据
Android Styles and Themes页面,您必须使用单独的颜色资源来设置颜色.
(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.)
例如
<item name="android:windowBackground">@color/custom_theme_color</item>