1

我想设置整个应用程序主题。而且我的代码在 ICe-Creme Sandwich 及更高版本中运行良好,但它不适用于较低版本,而不是给出任何错误。

这是我的代码:

我在调用 setcontentView(); 之前使用下面的代码设置主题;

SharedPreferences pref=context.getSharedPreferences(HomeSAFEPref.HomeSAFEPref,0);
        int position= pref.getInt("BackgroundPosition", 0);

        switch (position) {
        case 0:

            context.setTheme(R.style.Background0);

            break;

        case 1:

            context.setTheme(R.style.Background1);

            break;

        case 2:

            context.setTheme(R.style.Background2);

            break;

        case 3:
            context.setTheme(R.style.Background3);
            break;

        case 4:
            context.setTheme(R.style.Background4);
            break;
        }

上面的代码在较高版本上运行良好,但不适用于较低版本。

这是样式代码:

<style name="Background0" parent="@android:style/Theme.Black.NoTitleBar">
        <item name="android:windowBackground">@drawable/bigl_1</item>
        <item name="android:windowNoTitle">true</item>
    </style>

请建议

4

1 回答 1

4

你应该在调用 super.onCreate() 和 setContentView() 之前设置你的主题。如果还是不行,那么很可能是框架的问题。

参考这个这个

于 2013-05-27T10:40:40.790 回答