2 Replies - 6408 Views - Last Post: 28 July 2012 - 10:35 AM

#1 Barem0to   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 07-June 12

How to create and override android themes using xml?

Posted 27 July 2012 - 12:48 PM

Hey guys, I'm attempting to create my first ever android app, and I need help on creating my own theme and also overriding the built in ones. So I attempted to override the built in one by changing the background to red. However, when I run it, it's still the same color.

Here's the styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="AppTheme" parent="android:Theme.Light">
        <item name="android:background">@color/Red</item>
    </style>

</resources>


Here's the mycolor.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="Blue">#0000ff</color>
    <color name="Red">#ff0000</color>
    <color name="Green">#008000</color>
    <color name="Yellow">#ffff00</color>
    <color name="Cyan">#00ffff</color>
    <color name="Dark_Blue">#0000a0</color>
    <color name="Light_Blue">#add8e6</color>
    <color name="Purple">#800080</color>
    <color name="Lime">#00ff00</color>
    <color name="Fuchsia">#ff00ff</color>
    <color name="White">#ffffff</color>
    <color name="Silver">#c0c0c0</color>
    <color name="Grey">#808080</color>
    <color name="Black">#000000</color>
    <color name="orange">#ffa500</color>
    <color name="Brown">#a52a2a</color>
    <color name="Maroon">#800000</color>
    <color name="Olive">#808000</color>
    <color name="Pink">#f52887</color>
    
</resources>


Here's my manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="sun.aio.converter"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Converter"
            android:label="@string/title_activity_converter" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


I don't know why the background isn't changing to red... Instead it keeps the layout of Android.Theme.Light. So I need help with that.

Also is there a tutorial on this site on how to build your own Theme? I don't care if it's using Java or xml.

Thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: How to create and override android themes using xml?

#2 H3R3T1C   User is offline

  • Android Expert
  • member icon

Reputation: 278
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: How to create and override android themes using xml?

Posted 27 July 2012 - 06:52 PM

Well I assume you want to change the window background to red? You need to replace
<item name="android:background">@color/Red</item>

with
<item name="android:windowBackground">@color/red</item>

Was This Post Helpful? 0
  • +
  • -

#3 Barem0to   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 07-June 12

Re: How to create and override android themes using xml?

Posted 28 July 2012 - 10:35 AM

Yea I tried that and it still appears as the light theme background...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1