我的申请中有两个主题.我有一个蓝色背景的蓝色主题:
<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>
我还有一个白色背景的白色主题:
<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>
<application android:allowBackup="true" android:icon="@drawable/launcher_icon" android:label="@string/app_name" android:theme="@style/Theme.AppTheme" >
然后我在onCreate的ActivityBase类中设置了蓝色主题:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } setTheme(R.style.Theme_BlueTheme); }