我添加了一个颜色文件夹,带有这个xml文件:
<?xml version="1.0" encoding="utf-8"?>
<item
xmlns:android="http://schemas.android.com/apk/res/android">
<color name="orange">#FF9912</color>
</item>
但是当我在我在values文件夹中创建的screen_display.xml中输入值时。它给了我一个错误:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme.Background" parent="@android:style/Theme">
<item name="android:windowNoTitle"> true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@colors/color/orange</item>
</style>
</resources>
UPDATE
<activity android:name=".EasyLearningActivity"
android:launchMode="singleTask"
android:alwaysRetainTaskState="true"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:theme="MyTheme.Background"...shows mistake, saying that Strying type inst allowed :(
>
答案 0 :(得分:11)
请知道这个 在values文件夹中创建两个xml文件第一个
color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="orange">#FF9912</color>
</resources>
styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme.Background" parent="@android:style/Theme">
<item name="android:windowNoTitle"> true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowBackground">@color/orange</item>
</style>
</resources>
在清单文件中:
<activity android:name=".EasyLearningActivity"
android:launchMode="singleTask"
android:alwaysRetainTaskState="true"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:theme="@style/MyTheme.Background"></activity>
答案 1 :(得分:0)
这是@color,而不是@colors ......
您是否在清单中为应用程序标记设置了android:theme属性以使用MyTheme.Background?
答案 2 :(得分:0)
您无法直接使用android:theme
字符串。
您需要包含其中一种风格,例如**@style/**MyTheme.Background
。
答案 3 :(得分:0)
感谢color.xml,经过7个小时的研究和很多挫折之后,我现在有了一个像我想要的紫色动作栏。
<color name="orange" type="color">#FF9912</color>
<color name="red" type="color">#FF0000</color>
<color name="blue" type="color">#FF33B5E5</color>
<color name="purple" type="color">#FFAA66CC</color>
<color name="green" type="color">#FF99CC00</color>
<color name="darkblue" type="color">#FF0099CC</color>
<color name="darkpurple" type="color">#FF9933CC</color>
<color name="darkgreen" type="color">#FF669900</color>
<color name="darkorange" type="color">#FFFF8800</color>
<color name="darkred" type="color">#FFCC0000</color>
<!--Black #000000 (0,0,0)
White #FFFFFF (255,255,255)
Red #FF0000 (255,0,0)
Lime #00FF00 (0,255,0)
Blue #0000FF (0,0,255)
Yellow #FFFF00 (255,255,0)
Cyan / Aqua #00FFFF (0,255,255)
Magenta / Fuchsia #FF00FF (255,0,255)
Silver #C0C0C0 (192,192,192)
Gray #808080 (128,128,128)
Maroon #800000 (128,0,0)
Olive #808000 (128,128,0)
Green #008000 (0,128,0)
Purple #800080 (128,0,128)
Teal #008080 (0,128,128)
Navy #000080 (0,0,12-->
<!--color name="orange" type="color">#FFFFBB33</color-->
<!--<color name="red" type="color">#FFFF4444</color-->