Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply a theme depending on Android version

Tags:

android

themes

Currently I have a theme specified in AndroidManifest.xml file:

android:theme="@android:style/Theme.Holo.Light"

Now I'm working to create the application backward compatible. As long as Gingerbread doesn't have Theme.Holo.Light I'll use Theme.Light but how to apply needed theme depending on OS version?

like image 504
Eugene Avatar asked May 14 '26 22:05

Eugene


1 Answers

Use resource qualifiers for your values folder:

e.g. res/values-v11

Have your style reference Theme.Light in the standard res/values/styles.xml, then reference Theme.Holo.Light in res/values-v11/styles.xml. If it's running on API 11+, it will automatically choose Holo; otherwise, it will fall back to the standard Theme.Light specified in res/values/styles.xml.

like image 141
Kevin Coppock Avatar answered May 16 '26 21:05

Kevin Coppock



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!