[英]Android ActionBar styling with ActionBar style generator
I am using this ActionBar Style Generator to style the ActionBar
. 我使用这个动作条样式生成器样式的ActionBar
。 I have copied the style file and the drawables into the respective folders. 我已将样式文件和可绘制对象复制到相应的文件夹中。 But when I try to run the app the following error appears. 但是,当我尝试运行该应用程序时,会出现以下错误。
This is the style.xml
file. 这是style.xml
文件。 The error appears after I add this. 添加此错误后出现错误。 I am assigning this theme to an activity in AndroidManifest.xml
file: 我将此主题分配给AndroidManifest.xml
文件中的活动:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Example" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">@drawable/selectable_background_example</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Example</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Example</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Example</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Example</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Example</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_example</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_example</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Example</item>
</style>
<style name="ActionBar.Solid.Example" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@drawable/ab_solid_example</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_example</item>
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_example</item>
<item name="android:progressBarStyle">@style/ProgressBar.Example</item>
</style>
<style name="PopupMenu.Example" parent="@android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>
</style>
<style name="DropDownListView.Example" parent="@android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_example</item>
</style>
<style name="ActionBarTabStyle.Example" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_example</item>
</style>
<style name="DropDownNav.Example" parent="@android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@drawable/spinner_background_ab_example</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>
<item name="android:dropDownSelector">@drawable/selectable_background_example</item>
</style>
<style name="ProgressBar.Example" parent="@android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_example</item>
</style>
<style name="ActionButton.CloseMode.Example" parent="@android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_example</item>
</style>
</resources>
The error I got is: 我得到的错误是:
Execution failed for task ':app:processDebugManifest'.
> com.android.manifmerger.ManifestMerger2$MergeFailureException: org.xml.sax.SAXException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
Please help me. 请帮我。 This issue is driving me nuts! 这个问题使我发疯!
Wherever you declare the parent
tag with @android:style
, you need to change it to @style
. 无论您在使用@android:style
声明parent
标签的任何地方,都需要将其更改为@style
。 For example: 例如:
parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
Should change to: 应更改为:
parent="@style/Widget.Holo.Light.ActionBar.Solid">
Make the same change as above to other styles that you have declared in your styles.xml
file. 对您在styles.xml
文件中声明的其他样式进行与上述相同的更改。
Tip : If you are using Eclipse
to develop Android, press Ctrl+Left-Click at the same time on a parent
tag to show the style's definition. 提示 :如果使用Eclipse
开发Android,请同时在parent
标记上按Ctrl +向左键单击以显示样式的定义。 If the style is defined correctly, pressing Ctrl+Left-Click will open the corresponding Android's styles.xml
file. 如果正确定义了样式,请按Ctrl +左键单击将打开相应的Android的styles.xml
文件。 If the styles.xml
file is not opened after you Ctrl+Left-Click on it, then you know you have a problem with your Android's tag declaration. 如果在您按住Ctrl +左键单击后未打开styles.xml
文件,则说明您的Android标签声明存在问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.