如何使用Holo.Light主题,回落到'光'的pre-蜂窝设备? [英] How to use Holo.Light theme, and fall back to 'Light' on pre-honeycomb devices?

查看:139
本文介绍了如何使用Holo.Light主题,回落到'光'的pre-蜂窝设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用在支持的设备上的 Holo.Light 主题,并回落到正规主题在其他设备上。

I'd like to use the Holo.Light theme on devices that support it, and fall back to the regular Light theme on other devices.

目前,引用 Holo.Light 工作正常3.0+,但旧的API只是恢复到默认的黑暗的主题。我能达到我想要与风格的继承?

At the moment, referencing Holo.Light works fine on 3.0+, but older APIs simply revert to the default 'dark' theme. Can I achieve what I want with with style inheritance?

推荐答案

您必须创建一个自定义主题,并将其保存在某些目录最终确定这个主题为默认一个用于应用程序

You have to create a custom theme and save it in some directories to finally set this theme as the default one for the app

首先,在价值增加的themes.xml是这样的:

First, in values add a themes.xml like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <!-- Any customizations for your app running on pre-3.0 devices here -->
    </style>
</resources> 

然后,创建一个名为价值-V11(安卓3.0+)在res目录的目录,并把一个的themes.xml这样

Then, create a directory with the name "values-v11" (Android 3.0+ ) in the res directory and put a themes.xml like this

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.Holo.Light">
        <!-- Any customizations for your app running on 3.0+ devices here -->
    </style>
</resources>

最后,创建一个名为价值-V14(安卓4.0+)在res目录的目录并创建的themes.xml

Finally, create a directory with the name "values-v14" (Android 4.0+) in the res directory and create a themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
        <!-- Any customizations for your app running on 4.0+ devices here -->
    </style>
</resources>

随着DeviceDefault您的应用程序八方通看起来完美的在任何公司(HTC三星...)的加创建自定义主题为Android 4

With the DeviceDefault your app allways look perfect in any device of any company (HTC Samsung ... ) that add created custom themes for Android 4

编辑:三星的接口(的TouchWiz)不尊重这个功能和应用程序将是非常丑陋的在三星的设备。其最好把霍洛主题:(

最后,在你的manifest.xml

Finally in your manifest.xml

 <application
        ...
        android:theme="@style/MyAppTheme">

这篇关于如何使用Holo.Light主题,回落到'光'的pre-蜂窝设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆