繁体   English   中英

如何获取清单文件android的应用程序主题

[英]How to get the application theme of the manifest file android

我有一个需要多个主题的android应用。 这些主题彼此完全不同,但是我需要动态地了解当前选择了哪个主题。

在这里,您可以找到我的android应用的application标签的示例。 在这里,您可以看到主题设置为Theme1,但也可以是Theme2,Theme3,...

<application
    android:name="be.genius.gticket.adapter.MyApplicationClass"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="gticket"

    android:theme="@style/Theme1" >
int themeId = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.theme;


switch (themeId)
        {
        default:
        case THEME_DEFAULT: // use the theme names in cases as per requirements
            break;
        case THEME_WHITE:
            activity.setTheme(R.style.Theme_White);
            break;
        case THEME_BLUE:
            activity.setTheme(R.style.Theme_Blue);
            break;
        }

希望对您有所帮助:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM