【发布时间】:2014-04-16 19:33:50
【问题描述】:
我最近开始了 android 开发,它通常没有问题。但是,尽管遵循信中的指南/说明(或者我可以说),但我似乎无法将主题应用于操作栏。
我使用 Android 操作栏样式生成器生成了我的主题,将 res 文件夹添加到我的项目中,并编辑了清单文件以使用新主题。我在 values 和 values-v14 中都有一个样式,后者使用“android:”。
预期结果 vs 当前结果:
res/values/styles_amulettheme.xml:
<?xml version="1.0" encoding="utf-8"?>
<!-- File created by the Android Action Bar Style Generator
Copyright (C) 2011 The Android Open Source Project
Copyright (C) 2012 readyState Software Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<style name="Theme.Amulettheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<item name="actionBarItemBackground">@drawable/selectable_background_amulettheme</item>
<item name="popupMenuStyle">@style/PopupMenu.Amulettheme</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Amulettheme</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle.Amulettheme</item>
<item name="actionDropDownStyle">@style/DropDownNav.Amulettheme</item>
<item name="actionBarStyle">@style/ActionBar.Solid.Amulettheme</item>
<item name="actionModeBackground">@drawable/cab_background_top_amulettheme</item>
<item name="actionModeSplitBackground">@drawable/cab_background_bottom_amulettheme</item>
<item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Amulettheme</item>
<!-- Light.DarkActionBar specific -->
<item name="actionBarWidgetTheme">@style/Theme.Amulettheme.Widget</item>
</style>
<style name="ActionBar.Solid.Amulettheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/ab_solid_amulettheme</item>
<item name="backgroundStacked">@drawable/ab_stacked_solid_amulettheme</item>
<item name="backgroundSplit">@drawable/ab_bottom_solid_amulettheme</item>
<item name="progressBarStyle">@style/ProgressBar.Amulettheme</item>
</style>
<style name="ActionBar.Transparent.Amulettheme" parent="@style/Widget.AppCompat.ActionBar">
<item name="background">@drawable/ab_transparent_amulettheme</item>
<item name="progressBarStyle">@style/ProgressBar.Amulettheme</item>
</style>
<style name="PopupMenu.Amulettheme" parent="@style/Widget.AppCompat.PopupMenu">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_amulettheme</item>
</style>
<style name="DropDownListView.Amulettheme" parent="@style/Widget.AppCompat.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_amulettheme</item>
</style>
<style name="ActionBarTabStyle.Amulettheme" parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_amulettheme</item>
</style>
<style name="DropDownNav.Amulettheme" parent="@style/Widget.AppCompat.Spinner.DropDown.ActionBar">
<item name="android:background">@drawable/spinner_background_ab_amulettheme</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_amulettheme</item>
<item name="android:dropDownSelector">@drawable/selectable_background_amulettheme</item>
</style>
<style name="ProgressBar.Amulettheme" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_amulettheme</item>
</style>
<style name="ActionButton.CloseMode.Amulettheme" parent="@style/Widget.AppCompat.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_amulettheme</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Amulettheme.Widget" parent="@style/Theme.AppCompat">
<item name="popupMenuStyle">@style/PopupMenu.Amulettheme</item>
<item name="dropDownListViewStyle">@style/DropDownListView.Amulettheme</item>
</style>
</resources>
AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="quinn.anth.amulet"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Amulettheme" >
<activity
android:name="quinn.anth.amulet.MenuActivity"
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>
我们将不胜感激任何正确方向的帮助。
【问题讨论】:
-
设法修复它感谢您的所有帮助。我有一些错误命名的图像,所以按下时使用了错误的图像。聚焦/点击的项目列在 selectable_background_amulettheme.xml 下。