[英]How to color the background of the application in android
I added a color folder, with this xml file: 我添加了一个颜色文件夹,这个xml文件:
<?xml version="1.0" encoding="utf-8"?>
<item
xmlns:android="http://schemas.android.com/apk/res/android">
<color name="orange">#FF9912</color>
</item>
But when I put as the value in the screen_display.xml that i created in the values folder. 但是当我将值作为我在values文件夹中创建的screen_display.xml中的值。 It gives me a mistake:
它给了我一个错误:
<?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 :(
>
pls chk out this in values folder create two xml file first one 请在值文件夹中输出这个,先创建两个xml文件
color.xml color.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="orange">#FF9912</color>
</resources>
styles.xml 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>
In manifest file: 在清单文件中:
<activity android:name=".EasyLearningActivity"
android:launchMode="singleTask"
android:alwaysRetainTaskState="true"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:theme="@style/MyTheme.Background"></activity>
You can't use directly string for android:theme
. 你不能直接使用字符串
android:theme
。
You need to include one of the styles like **@style/**MyTheme.Background
. 您需要包含一个样式,如
**@style/**MyTheme.Background
。
Thanks for the color.xml , finally after 7 hours of research and lots of frustration I now have a purple action bar like I wanted. 感谢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-->
It's @color, not @colors... 这是@color,而不是@colors ......
and are you setting the android:theme attribute for your application tag in the manifest to use MyTheme.Background? 你在清单中为你的应用程序标签设置android:theme属性以使用MyTheme.Background吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.