Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different Theme for different Android SDK versions

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' 
like image 916
baynezy Avatar asked Feb 04 '12 10:02

baynezy


People also ask

Is Theme same as theme Android studio?

A style is a collection of attributes that specify the appearance for a single View . A style can specify attributes such as font color, font size, background color, and much more. A theme is a collection of attributes that's applied to an entire app, activity, or view hierarchy—not just an individual view.

How can I change my Android app theme?

In Android Studio, open themes. xml (app > res > values > themes > themes.

Can we change theme in Android Studio?

Go to File > Settings, now under IDE settings click on appearance and select the theme of your choice from the dropdown. File > Import Settings , select the file or your choice and select ok a pop up to restart the studio will open up click yes and studio will restart and your theme will be applied.


1 Answers

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.

like image 87
Kuffs Avatar answered Sep 27 '22 21:09

Kuffs