6

MinSDKVersion = 7 目标SDKVersion = 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, 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>

我怎样才能正确使用它?

真诚的 Marco Seiz

4

2 回答 2

6

为什么你的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>

于 2013-01-15T10:21:56.813 回答
2

将@Ahmad 提供的解决方案放在他说的目录中名为themes.xml的新文件中:-)

如果您将使用多语言和多主题,您可以看看我几分钟前做过的类似问题......并得到了回答:

同时多语言和多主题

于 2013-01-15T10:33:44.550 回答