首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android:如何在不同的android版本中使用不同的主题?

Android:如何在不同的android版本中使用不同的主题?
EN

Stack Overflow用户
提问于 2013-01-15 18:15:27
回答 2查看 14.3K关注 0票数 6

MinSDKVersion =7 TargetSDKVersion = 17

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

在版本低于3.1的设备上运行此应用程序时相同

我的文件夹结构:

清单:

代码语言:javascript
复制
    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyTheme" >

值-v11:

代码语言:javascript
复制
<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>

其他值文件夹:

代码语言:javascript
复制
<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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-01-15 18:21:57

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

代码语言:javascript
复制
<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:

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

值:

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

票数 6
EN

Stack Overflow用户

发布于 2013-01-15 18:33:45

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

如果你将使用多语言和多主题,你可以看看我几分钟前做过的一个类似的问题……得到的答案是:

Multilanguage and multitheme at same time

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14335453

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档