Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Android: How to use different themes for different android versions? - Stack Overfl...

Página 1 de 4

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no
Tell me more ×
registration required.

Android: How to use different themes for different android versions?

MinSDKVersion = 7 TargetSDKVersion = 17

If the user have SDKVersion 11 or higher I like to set the theme to Theme.Holo.Light. It doesn't works for me
here. When I launch the app on a 3.1 device it just uses the Theme.Light:

Same when I run this app on a device with lower version than 3.1

My Folderstructure:

http://stackoverflow.com/questions/14335453/android-how-to-use-different-themes-fo... 18/11/2013
Android: How to use different themes for different android versions? - Stack Overfl... Página 2 de 4

Manifest:

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >

values-v11:

<resources>

<!­­
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values­vXX/styles.xml on newer devices.
­­>
<style name="AppBaseTheme" parent="@android:style/Theme.Light">
<!­­
Theme customizations available in newer API levels can go in
res/values­vXX/styles.xml, while customizations related to
backward­compatibility can go here.
­­>
</style>

<!­­ Application theme. ­­>
<style name="AppTheme" parent="@android:style/Theme.Light">
<!­­ All customizations that are NOT specific to a particular API­level can go here
</style>

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">


<!­­ Any customizations for your app running on devices with Theme.Holo here ­­>
</style>

other values folders:

http://stackoverflow.com/questions/14335453/android-how-to-use-different-themes-fo... 18/11/2013
Android: How to use different themes for different android versions? - Stack Overfl... Página 3 de 4

<resources>

<!­­
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values­vXX/styles.xml on newer devices.
­­>
<style name="AppBaseTheme" parent="@android:style/Theme.Light">
<!­­
Theme customizations available in newer API levels can go in
res/values­vXX/styles.xml, while customizations related to
backward­compatibility can go here.
­­>
</style>

<!­­ Application theme. ­­>
<style name="AppTheme" parent="@android:style/Theme.Light">
<!­­ All customizations that are NOT specific to a particular API­level can go here
</style>

<style name="MyTheme" parent="@android:style/Theme.Light">


<!­­ Any customizations for your app running on devices with Theme.Holo here ­­>
</style>

How can I use this correctly?

Sincerely Marco Seiz

android themes manifest

asked Jan 15 at 10:15


Marco Seiz
126 18

2 Answers

Why do you have your theme twice in your styles.xml file?

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


<!­­ All customizations that are NOT specific to a particular API­level can go here
</style>

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">


<!­­ Any customizations for your app running on devices with Theme.Holo here ­­>
</style>

Delete the one you don't need(In this case the Theme.Light theme):

values-v11:

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">


<!­­ Any customizations for your app running on devices with Theme.Holo here ­­>
</style>

values:

<style name="MyTheme" parent="@android:style/Theme.Light">


<!­­ Any customizations for your app running on devices with Theme.Holo here ­­>
</style>

answered Jan 15 at 10:21


Ahmad
15.5k 5 27 62

I did that but it still showed the old theme and not the holo theme on my android 4.1 AND 3.1 device–
Marco Seiz Jan 15 at 10:27

Did you delete the duplications?– AhmadJan 15 at 10:28

Yep I did. I figured out the error. I had to create two folders for one language. For german: values-de AND values-
de-v11 and same for english... It works now :) Thanks for your helps and tips!– Marco Seiz Jan 15 at 10:33

http://stackoverflow.com/questions/14335453/android-how-to-use-different-themes-fo... 18/11/2013
Android: How to use different themes for different android versions? - Stack Overfl... Página 4 de 4

Place the solution provided by @Ahmad in new files called themes.xml on the directories he said :-)

If you'll use multilanguage and multithemes, you can take a look at a similar question I did some minutes
before... and got answered:

Multilanguage and multitheme at same time

answered Jan 15 at 10:33


Xavi
25 5

Not the answer you're looking for? Browse other questions tagged android themes

manifest or ask your own question.

http://stackoverflow.com/questions/14335453/android-how-to-use-different-themes-fo... 18/11/2013

You might also like