根据Android版本更改主题 [英] Change theme according to android version

查看:135
本文介绍了根据Android版本更改主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是preparing我的应用程序与蜂窝工作的顺利开展。我与Android的主题就一个小的美学问题。

I am preparing my app to work smoothly with honeycomb. I have an small aesthetics question regarding with the android theme.

有关蜂窝状,建议下面的主题被使用。

For honeycomb it is recommended that the following theme is used.

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

我怎样才能让我的应用程序使用的另一个主题,当它被用在previous版本?

How can I make my app use another theme when it is used in a previous version?

在此先感谢

推荐答案

修改:更新了3.0 SDK的发布版本

EDIT: Updated for released version of the 3.0 SDK.

要做到这一点的方法之一是设置<使用-SDK机器人:targetSdkVersion =11> 。你也应该把这个上面你的<应用> 定义。这会告诉系统使用了全息主题(如果可用),并且默认主题,否则。

One way to do this is to set <uses-sdk android:targetSdkVersion="11">. You should also place this above your <application> definition. This will tell the system to use the Holographic theme if it's available, and the default theme otherwise.

另一种方式做到这一点,是定义一个主题,比如的MyTheme ,继承自一个不同的主题,根据API级别/ OS版本。为此,您可以使用资源目录预选赛的。

Another way to do this, is to define a theme, say MyTheme, that inherits from a different theme depending on the API level / OS version. You can do this using resource directory qualifiers.

您的目录结构看起来是这样的:

Your directory structure could look like this:

res/
  values/
    styles.xml
  values-v11/
    styles.xml

RES /价值/ styles.xml的内容会是这样的:

<resources>
  <style name="MyTheme" parent="@android:style/Theme.Light">
    ...
  </style>
</resources>

和内容 RES /值-V11 / styles.xml 会是这样的:

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

<打击>需要注意的是,在未来,河洛主题可能并不总是有意义通过API级别,所以你可能需要调整这个方法以后。您也可以使用其他的目录限定词,如价值观大V11 等。这完全取决于你。

Note that in the future, the Holo theme may not always make sense by API level, so you may need to tweak this approach later on. You can also use other directory qualifiers such as values-large-v11 or the like. It's entirely up to you.

这篇关于根据Android版本更改主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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