I have two themes in my application. I have a blue theme with a blue background:
<style name="Theme.BlueTheme" parent="Theme.Sherlock">
<item name="android:panelBackground">@drawable/menu_hardkey_panel_actionbar</item>
<item name="android:buttonStyle">@style/ButtonAppTheme</item>
<item name="android:windowBackground">@drawable/bground_blue</item>
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
<item name="android:editTextStyle">@style/Widget.EditText.White</item>
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
<item name="android:textViewStyle">@style/whitestyle</item>
</style>
I also have a white theme with a white background:
<style name="Theme.AppTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="android:panelBackground">@drawable/menu_hardkey_panel_actionbar</item>
<item name="android:buttonStyle">@style/ButtonAppTheme</item>
<item name="android:windowBackground">@drawable/bground_white</item>
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
<item name="android:editTextStyle">@style/Widget.EditText.Black</item>
</style>
Everything works fine except the background is always the white one when I set the blue theme in code.
My application theme is set to the white theme in my manifest:
<application
android:allowBackup="true"
android:icon="@drawable/launcher_icon"
android:label="@string/app_name"
android:theme="@style/Theme.AppTheme" >
I then set the blue theme up in my ActivityBase class in onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
setTheme(R.style.Theme_BlueTheme);
}
You have to setTheme before you call super.onCreate() and setContentView().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With