Android Holo themes with backwards compatibility

可紊 提交于 2019-12-07 05:15:33

问题


I have built android app with supporting android:minSdkVersion="7" android:targetSdkVersion="15". I use my customized theme inheriting Android default theme.

so now i want to change whole application theme to Holo theme.Can any one help me on this.


回答1:


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.




回答2:


Try to use HoloEverywhere as parent theme.




回答3:


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



来源:https://stackoverflow.com/questions/10716514/android-holo-themes-with-backwards-compatibility

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