Android:如何为不同的Android版本使用不同的主题?

MinSDKVersion = 7
TargetSDKVersion = 17

如果用户拥有SDKVersion 11或更高版本,我想将主题设置为Theme.Holo.Light.
它在这里对我不起作用.当我在3.1设备上启动应用程序时,它只使用Theme.Light:

当我在版本低于3.1的设备上运行此应用程序时也是如此

我的文件夹结构:

表现:

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

值-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,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>

我怎样才能正确使用它?

诚挚
Marco Seiz

解决方法

为什么在styles.xml文件中有两次主题
<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主题):

值-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>

相关文章

以下为个人理解,如错请评 CE: 凭据加密 (CE) 存储空间, 实际路径/data/user_ce/ DE: 设备加密 (DE) 存...
转载来源:https://blog.csdn.net/yfbdxz/article/details/114702144 用EventLog.writeEvent打的日志(或...
事件分发机制详解 一、基础知识介绍 1、经常用的事件有:MotionEvent.ACTION_DOWN,MotionEvent.ACTION...
又是好久没有写博客了,一直都比较忙,最近终于有时间沉淀和整理一下最近学到和解决的一些问题。 最近进...
Android性能优化——之控件的优化 前面讲了图像的优化,接下来分享一下控件的性能优化,这里主要是面向...
android的开源库是用来在android上显示gif图片的。我在网上查了一下,大家说这个框架写的不错,加载大的...