Alex Rivera | Logout

How to use device default theme for app?

Asked 2012-03-22T23:33:57.903
43

I have an app that I want to develop for Android 2.1, 2.2, 2.3.3, 3.0/3.1 and 4.0.x. Between those API levels, there are about 3 different types of Themes. The latest 4.0.x theme is Holo.

Anyways, I want my app to use the default Android theme for whatever device it's on. If it's on a 4.0.x device, I want it to use Holo. If it's on 2.3.3 I want it to use the theme from that version of Android. etc...

Is there a simple way to approach this? I noticed that with 4.0, they added a Theme.DeviceDefault theme that you can use, but this doesn't help me for older API levels. What is the best approach to this?

Edit
Report

1 Answer

3

You can declare a theme in your values/styles.xml and then in your values-v11/styles.xml override it with the Holo-version:

values/styles.xml:

 <style name="DialogTheme" parent="@android:style/Theme.Dialog"></style>
 

values-v11/styles.xml:

 <style name="DialogTheme" parent="@android:style/Theme.Holo.Light.Dialog.NoActionBar"></style>

Do it that way, and you'll have Holo themes on API 11+ devices and regular themes on the others.

answered 2013-06-19T18:46:25.953

Your Answer