开发者

How to color the background of the application in android

开发者 https://www.devze.com 2023-04-07 18:54 出处:网络
I added a color folder, with this xml file: <?xml version=\"1.0\" encoding=\"utf-8\"?> <item xmlns:android=\"http://schemas.android.com/apk/res/android\">

I added a color folder, with this xml file:

    <?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. It gives me a mistake:

        <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <style name="MyTheme.Background" parent="@android:style/Theme">
          <item name="android:window开发者_如何学PythonNoTitle"> 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

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>

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>


It's @color, not @colors...

and are you setting the android:theme attribute for your application tag in the manifest to use MyTheme.Background?


You can't use directly string for android:theme.

You need to include one of the styles like **@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 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-->

0

精彩评论

暂无评论...
验证码 换一张
取 消