所以我使用了操作栏样式生成器来创建一个样式兼容模式设置为AppCompat
的主题。我下载了ZIP
文件并复制并粘贴了我文件夹中的所有文件,但是当运行模拟器时主题没有出现。
styles_actionstyle.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Actionstyle" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">@drawable/selectable_background_actionstyle</item >
<item name="popupMenuStyle">@style/PopupMenu.Actionstyle</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Actionstyle</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Actionstyle</item>
<item name="actionDropDownStyle">@style/DropDownNav.Actionstyle</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Actionstyle</item>
<item name="actionModeBackground">@drawable/cab_background_top_actionstyle</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_actionstyle</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Actionstyle</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">@style/Theme.Actionstyle.Widget</item>
</style>
<style name="ActionBar.Solid.Actionstyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/ab_solid_actionstyle</item>
<item name="backgroundStacked">@drawable/ab_stacked_solid_actionstyle</item>
<item name="backgroundSplit">@drawable/ab_bottom_solid_actionstyle</item>
<item name="progressBarStyle">@style/ProgressBar.Actionstyle</item>
</style>
<style name="ActionBar.Transparent.Actionstyle" parent="@style/Widget.AppCompat.ActionBar">
<item name="background">@drawable/ab_transparent_actionstyle</item>
<item name="progressBarStyle">@style/ProgressBar.Actionstyle</item>
</style>
<style name="PopupMenu.Actionstyle" parent="@style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_actionstyle</item>
</style>
<style name="DropDownListView.Actionstyle" parent="@style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_actionstyle</item>
</style>
<style name="ActionBarTabStyle.Actionstyle" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_actionstyle</item>
</style>
<style name="DropDownNav.Actionstyle" parent="@style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">@drawable/spinner_background_ab_actionstyle</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_actionstyle</item>
<item name="android:dropDownSelector">@drawable/selectable_background_actionstyle</item>
</style>
<style name="ProgressBar.Actionstyle" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_actionstyle</item>
</style>
<style name="ActionButton.CloseMode.Actionstyle" parent="@style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_actionstyle</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Actionstyle.Widget" parent="@style/Theme.AppCompat">
<item name="popupMenuStyle">@style/PopupMenu.Actionstyle</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Actionstyle</item>
</style>
</resources>
V14版本:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Actionstyle" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarItemBackground">@drawable/selectable_background_actionstyle</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Actionstyle</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Actionstyle</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Actionstyle</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Actionstyle</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Actionstyle</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_actionstyle</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_actionstyle</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Actionstyle</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">@style/Theme.Actionstyle.Widget</item>
</style>
<style name="ActionBar.Solid.Actionstyle" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/ab_background_textured_actionstyle</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_actionstyle</item>
<item name="android:backgroundSplit">@drawable/ab_background_textured_actionstyle</item>
<item name="android:progressBarStyle">@style/ProgressBar.Actionstyle</item>
</style>
<style name="ActionBar.Transparent.Actionstyle" parent="@style/Widget.AppCompat.ActionBar">
<item name="android:background">@drawable/ab_transparent_actionstyle</item>
<item name="android:progressBarStyle">@style/ProgressBar.Actionstyle</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Actionstyle.Widget" parent="@style/Theme.AppCompat">
<item name="android:popupMenuStyle">@style/PopupMenu.Actionstyle</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Actionstyle</item>
</style>
</resources>
清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.blooddonation2" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Actionstyle" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>