I am having some troubles to provide different styles resources for gingerbread or older versions of android.
I have defined 2 different style pages. the normal Styles and the Styles-v11. For android 3.0 and UP works just fine, everything is OK. My problem is when I try on gingerbread it just ignores the style changes.
Styles:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Styles for v1 to v10
-->
<style name="AppBaseTheme" parent="android:Theme.Light"></style>
<style name="DarkTheme" parent="android:Theme"></style>
<style name="Performance" parent="android:Theme"></style>
<style name="LightTheme" parent="android:Theme.Light"></style>
<style name="ColorsTheme" parent="android:Theme.Holo"></style>
<style name="OsuTheme" parent="android:Theme.Light"></style>
<style name="BrazilTheme" parent="android:Theme"></style>
<style name="NeonTheme" parent="android:Theme">
<item name="android:windowBackground">@android:color/black</item>
</style>
</resources>
Styles-v11:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Styles v11
-->
<style name="AppBaseTheme" parent="android:Theme.Light"></style>
<style name="DarkTheme" parent="android:Theme.Holo"></style>
<style name="Performance" parent="android:Theme.Holo"></style>
<style name="LightTheme" parent="android:Theme.Holo.Light"></style>
<style name="ColorsTheme" parent="android:Theme.Holo"></style>
<style name="OsuTheme" parent="android:Theme.Holo.Light"></style>
<style name="BrazilTheme" parent="android:Theme.Holo"></style>
<style name="NeonTheme" parent="android:Theme.Holo">
<item name="android:windowBackground">@android:color/black</item>
</style>
</resources>
My app have a settings to check which theme is active.
switch (ThemesActivity.newTheme) {
case ThemesActivity.THEME_DARK:
setTheme(R.style.DarkTheme);
setContentView(R.layout.activity_main_dark);
break;
case ThemesActivity.THEME_LIGHT:
setTheme(R.style.LightTheme);
setContentView(R.layout.activity_main_light);
break;
case ThemesActivity.THEME_COLORS:
setTheme(R.style.ColorsTheme);
setContentView(R.layout.activity_main_colors);
break;
case ThemesActivity.THEME_NEON:
setTheme(R.style.NeonTheme);
setContentView(R.layout.activity_main_neon);
break;
case ThemesActivity.THEME_PERF:
setTheme(R.style.Performance);
setContentView(R.layout.activity_main_performance);
break;
case ThemesActivity.THEME_OSU:
setTheme(R.style.OsuTheme);
setContentView(R.layout.activity_main_osu);
break;
case ThemesActivity.THEME_BRAZIL:
setTheme(R.style.BrazilTheme);
setContentView(R.layout.activity_main_brazil);
break;
default:
setTheme(R.style.DarkTheme);
setContentView(R.layout.activity_main_dark);
break;
}
The problem is doesn't matter which theme is active in Gingerbread! ALWAYS loads the default app theme :(
I can't figure out what is going on wrong and why the theme change is not working for older versions.
Thank you very much.
edit:
I've tried also using:
<style name="OsuTheme" parent="@android:style/Theme.Light"></style>
And still the same :( the theme doesn't change at run time, it only changes if I set the theme on the manifest.
On the manifest the themes work fines, the problem is when I try to change it during runtime.
<style name="LightTheme" parent="android:Theme.Light"></style>
<style name="ColorsTheme" parent="android:Theme.Holo"></style>
The main problem is that Gingerbread just doesn't have style resources from themes that you extending. Thats why it load default resources.