Search code examples
androidthemesandroid-4.0-ice-cream-sandwich

Difference between pre ICS and post ICS Holo theme related


I have a couple of app that were created with Android 1.6 and after. The problem is when I run these app on recent Android (device or simulator) like ICS, I don't have the Holo theme.

I know i can find a lot of thread on how to specify the theme but when I create a new app now, I have the new theme without any lines of code.

I don't want to have ICS theme on all android version, just ICS theme on ICS, like new holo buttons style on ICS and old grey style for older. Now I just have grey buttons for all versions.

I can create new empty projects and copy all my files into it but there must be a hidden value somewhere to chenge this.

In my manifest I have:

<uses-sdk android:minSdkVersion="3" />
<uses-sdk android:targetSdkVersion="14" />

What can be the difference between old and new created projects ?


Solution

  • What I'm understanding is that you want your app to switch between the legacy (classic) theme and the new Holo theme based on API version.

    First, in your values (res/values) folder make a new xml. Call it styles.xml. It should contain these lines:

    <resources>
    <style name="AppTheme" parent="@android:style/Theme.Black"/>
    </resources> 
    

    Then make a new folder in res called values-v11. In this new folder make another new xml. Also name it styles.xml This file should contain these lines:

    <resources>
    <style name="AppTheme" parent="@android:style/Theme.Holo"/>
    </resources>
    

    Then in your AndroidManifest.xml you Application node should contain this line:

    android:theme="@style/AppTheme"
    

    Now on devices with Honeycomb or higher you get the Holo theme and for everything else, you get the old classic theme. You can easily experiment with this to suit your needs - this is the general way to switch between themes based on API version.