Is there a way to use a different theme depending on which SDK version the application is installed on?
The reason I ask is because I want to support all the way back to SDK version 8, but for those users that have ICS I want to be able to follow the design standards for ICS and use the Holo theme.
I can see from Program different layouts for different versions in android that I can have a folder values-v14 which will have a theme.xml to override the theme declaration. However, it won't compile if I reference Theme.Holo. I believe this is because I have the following in my AndroidManifest.xml
<uses-sdk android:minSdkVersion="8" />
<uses-sdk android:targetSdkVersion="11"/>
Any pointers would be much appreciated.
UPDATE:- OK so here are my files:- AndroidManifest.xml:
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:name=".Refunder"
android:theme="@style/MainTheme"
>
res/values/themes.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:typeface">normal</item>
<item name="android:textSize">15sp</item>
</style>
</resources>
res/values-v11/themes.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="@android:style/Theme.Holo">
<item name="android:typeface">normal</item>
<item name="android:textSize">15sp</item>
</style>
</resources>
This is in accordance with the article I read here:- http://android-developers.blogspot.com/2012/01/holo-everywhere.html
When I do this I get a compile error in Eclipse saying that:-
error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Theme.Holo'
What you are doing (with your values-v14 folder) is correct. You just need to change your Build Target to allow it to compile. (right click your project, choose properties, select Android, Choose Android 14 or above)
Make sure you do not use any features greater than your android:minSdkVersion as it will cause a Force Close if used on an earlier version of Android.