Android: How to handle theming for older SDK's

为君一笑 提交于 2019-12-11 18:04:08

问题


I have an app that is minSDK 10, target's 14. I'd love to use the Light.Holo Theme (if available for device--and falls back to light theme for older device). Is there a way I can do this this?

It seems it defaults to Dark.Holo when you target 14, but when I try to add any other theme, it overwrites it and makes it look older on newer devices.


回答1:


You need to provide separate styles for both platforms to ensure that the correct style will be found at runtime.

In your res/values/styles.xml file, create the following style:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.MyTheme" parent="@android:style/Theme.Light" />
</resources>

In your res/values-v11/styles.xml file, create the following style:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.MyTheme" parent="@android:style/Theme.Holo.Light" />
</resources>

In your AndroidManifest.xml file, use the following line for your application's theme:

android:theme="@style/Theme.MyTheme"



回答2:


I think these answers might fit: Set Holo theme in older Android versions?

Basically they're recommending copying the themes into your own project so they're available to all users



来源:https://stackoverflow.com/questions/11146424/android-how-to-handle-theming-for-older-sdks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!