Android的:如何使用不同的主题不同的Andr​​oid版本? [英] Android: How to use different themes for different android versions?

查看:120
本文介绍了Android的:如何使用不同的主题不同的Andr​​oid版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的minSdkVersion = 7 TargetSDKVersion = 17

MinSDKVersion = 7 TargetSDKVersion = 17

如果用户有SDKVersion 11或更高,我喜欢设置主题Theme.Holo.Light。 它不会在这里为我工作。当我推出一个3.1设备上的应用程序,它只是使用了Theme.Light:

If the user have SDKVersion 11 or higher I like to set the theme to Theme.Holo.Light. It doesn't works for me here. When I launch the app on a 3.1 device it just uses the Theme.Light:

同样的,当我运行此程序的设备上使用版本低于3.1

Same when I run this app on a device with lower version than 3.1

我的Folderstructure:

My Folderstructure:

清单:

    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyTheme" >

值-V11:

values-v11:

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@android:style/Theme.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="@android:style/Theme.Light">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>


<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <!-- Any customizations for your app running on devices with Theme.Holo here -->
</style>

其他值的文件夹:

<resources>

<!--
    Base application theme, dependent on API level. This theme is replaced
    by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@android:style/Theme.Light">
    <!--
        Theme customizations available in newer API levels can go in
        res/values-vXX/styles.xml, while customizations related to
        backward-compatibility can go here.
    -->
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="@android:style/Theme.Light">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>

    <style name="MyTheme" parent="@android:style/Theme.Light">
    <!-- Any customizations for your app running on devices with Theme.Holo here -->
</style>

我如何使用正确的?

真诚 马可Seiz

推荐答案

为什么你有你的主题两次在styles.xml文件?

Why do you have your theme twice in your styles.xml file?

<style name="AppTheme" parent="@android:style/Theme.Light">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>


<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <!-- Any customizations for your app running on devices with Theme.Holo here -->
</style>

删除你不需要(在这种情况下,Theme.Light主题)之一:

Delete the one you don't need(In this case the Theme.Light theme):

值-V11:

<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
    <!-- Any customizations for your app running on devices with Theme.Holo here -->
</style>

值:

<style name="MyTheme" parent="@android:style/Theme.Light">
    <!-- Any customizations for your app running on devices with Theme.Holo here -->
</style>

这篇关于Android的:如何使用不同的主题不同的Andr​​oid版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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