Android Holo themes with backwards compatibility

こ雲淡風輕ζ 提交于 2019-12-05 08:32:24
Bannane

You can implement a "style selector" by using different style XMLs.

Just define a theme named "StyleSelector" or something like that in /res/**values**/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="ThemeSelector" parent="@android:style/Theme.Black">
    ... Your theme definitions
    </style>
</resources>

Then create a /res/**values-v11**/styles.xml:

<resources>
    <style name="ThemeSelector" parent="@android:style/Theme.Holo">
    </style>
</resources>

Now just apply your theme with "@style/ThemeSelector" and let Android do the magic. On older Android versions, your theme definition will be loaded, on newer versions with Holo-Support, your theme will be derived from Holo.

Try to use HoloEverywhere as parent theme.

Just modify the application tag in the AndroidManifest.xml that it contains the theme:

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

For example like this:

<application android:icon="@drawable/ic_launcher"
             android:label="@string/app_name"
             android:theme="@style/Theme.Holo">

Or you can do it on a per Activity basis. Here is the relevant documentation: https://developer.android.com/guide/topics/ui/themes.html

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