0

我在我的应用程序中使用 ActionBarSherlock 和 HoloEverywhere。我使用 ActionBar 样式生成器来生成我的样式,然后手动修改它们以获取文本颜色等。

我有一个问题,我的 ActionBar 在我的 Android 4.2 设备上看起来正确(即橙色和白色文本),但在我的 Android 2.3 设备上,ActionBar 是黑色和灰色文本。

有谁知道这可能是什么原因?

在此处输入图像描述

<style name="Theme.MyApp" parent="@style/Holo.Theme.Light.DarkActionBar">
    <item name="android:actionBarItemBackground">@drawable/selectable_background_MyApp</item>
    <item name="android:popupMenuStyle">@style/PopupMenu.MyApp</item>
    <item name="android:dropDownListViewStyle">@style/DropDownListView.MyApp</item>
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle.MyApp</item>
    <item name="android:actionDropDownStyle">@style/DropDownNav.MyApp</item>
    <item name="android:actionBarStyle">@style/ActionBar.Solid.MyApp</item>
    <item name="android:actionModeBackground">@drawable/cab_background_top_MyApp</item>
    <item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_MyApp</item>
    <item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.MyApp</item>
    <!-- <item name="android:textColorPrimary">#FFFFFF</item> -->
    <item name="android:spinnerDropDownItemStyle">@style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>

</style>

<style name="ActionBar.Solid.MyApp" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/ab_solid_MyApp</item>
    <item name="android:backgroundStacked">@drawable/ab_stacked_solid_MyApp</item>
    <item name="android:backgroundSplit">@drawable/ab_bottom_solid_MyApp</item>
    <item name="android:progressBarStyle">@style/ProgressBar.MyApp</item>
    <item name="android:titleTextStyle">@style/ActionBar.Solid.MyApp.TitleTextStyle</item>

</style>

<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textAppearance">@style/ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle</item>
</style>

<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle" parent="@android:style/Widget">
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">18sp</item>
</style>

<style name="ActionBar.Solid.MyApp.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">18sp</item>
    <!-- <item name="android:fontFamily">sans-serif-medium</item> -->
</style>

<style name="ActionBar.Transparent.MyApp" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/ab_transparent_MyApp</item>
    <item name="android:progressBarStyle">@style/ProgressBar.MyApp</item>
</style>

<style name="PopupMenu.MyApp" parent="@android:style/Widget.Holo.ListPopupWindow">
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_MyApp</item> 
</style>

<style name="DropDownListView.MyApp" parent="@android:style/Widget.Holo.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_MyApp</item>
</style>

<style name="ActionBarTabStyle.MyApp" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_MyApp</item>
</style>

<style name="DropDownNav.MyApp" parent="@android:style/Widget.Holo.Spinner">
    <item name="android:background">@drawable/spinner_background_ab_MyApp</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_MyApp</item>
    <item name="android:dropDownSelector">@drawable/selectable_background_MyApp</item>
</style>

<style name="ProgressBar.MyApp" parent="@android:style/Widget.Holo.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/progress_horizontal_MyApp</item>
</style>

<style name="ActionButton.CloseMode.MyApp" parent="@android:style/Widget.Holo.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_MyApp</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.MyApp.Widget" parent="@android:style/Theme.Holo">
    <item name="android:popupMenuStyle">@style/PopupMenu.MyApp</item>
    <item name="android:dropDownListViewStyle">@style/DropDownListView.MyApp</item>
</style>

- - - - - - - - 编辑 - - - - - - - - - - -

在此处输入图像描述

所以我现在遇到了一个问题,即操作栏在 Android 2.3 设备上占据了整个屏幕(但在 Android 4.2 上运行良好)。我需要从父属性中删除“android:”吗?

parent="@android:style/Widget.Holo.ListPopupWindow"

当我尝试这个时,Eclipse 无法找到主题。

 <resources xmlns:android="http://schemas.android.com/apk/res/android">

 <style name="Theme.MyApp" parent="@style/Holo.Theme.Light.DarkActionBar">
    <item name="android:actionBarItemBackground">@drawable/selectable_background_MyApp</item>
    <item name="android:popupMenuStyle">@style/PopupMenu.MyApp</item>
    <item name="android:dropDownListViewStyle">@style/DropDownListView.MyApp</item>
    <item name="android:actionBarTabStyle">@style/ActionBarTabStyle.MyApp</item>
    <item name="android:actionDropDownStyle">@style/DropDownNav.MyApp</item>
    <item name="android:actionBarStyle">@style/ActionBar.Solid.MyApp</item>
    <item name="android:actionModeBackground">@drawable/cab_background_top_MyApp</item>
    <item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_MyApp</item>
    <item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.MyApp</item>
    <!-- <item name="android:textColorPrimary">#FFFFFF</item> -->
    <item name="android:spinnerDropDownItemStyle">@style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>

    <item name="actionBarItemBackground">@drawable/selectable_background_MyApp</item>
    <item name="popupMenuStyle">@style/PopupMenu.MyApp</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.MyApp</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.MyApp</item>
    <item name="actionDropDownStyle">@style/DropDownNav.MyApp</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.MyApp</item>
    <item name="actionModeBackground">@drawable/cab_background_top_MyApp</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_MyApp</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.MyApp</item>
    <!-- <item name="textColorPrimary">#FFFFFF</item> -->
    <item name="spinnerDropDownItemStyle">@style/ActionBar.Solid.MyApp.NavigationDropDownStyle</item>

</style>

<style name="ActionBar.Solid.MyApp" parent="@android:style/Widget.Holo.Light.ActionBar">
    <item name="android:background">@drawable/ab_solid_MyApp</item>
    <item name="android:backgroundStacked">@drawable/ab_stacked_solid_MyApp</item>
    <item name="android:backgroundSplit">@drawable/ab_bottom_solid_MyApp</item>
    <item name="android:progressBarStyle">@style/ProgressBar.MyApp</item>
    <item name="android:titleTextStyle">@style/ActionBar.Solid.MyApp.TitleTextStyle</item>

    <item name="background">@drawable/ab_solid_MyApp</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_MyApp</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_MyApp</item>
    <item name="progressBarStyle">@style/ProgressBar.MyApp</item>
    <item name="titleTextStyle">@style/ActionBar.Solid.MyApp.TitleTextStyle</item>

</style>

<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textAppearance">@style/ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle</item>

</style>

<style name="ActionBar.Solid.MyApp.NavigationDropDownStyle.TextStyle" parent="@android:style/Widget">
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">18sp</item>

</style>

<style name="ActionBar.Solid.MyApp.TitleTextStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
    <item name="android:textColor">@color/white</item>
    <item name="android:textSize">18sp</item>

    <!-- <item name="android:fontFamily">sans-serif-medium</item> -->
</style>

<style name="ActionBar.Transparent.MyApp" parent="@android:style/Widget.Holo.ActionBar">
    <item name="android:background">@drawable/ab_transparent_MyApp</item>
    <item name="android:progressBarStyle">@style/ProgressBar.MyApp</item>

    <item name="background">@drawable/ab_transparent_MyApp</item>
    <item name="progressBarStyle">@style/ProgressBar.MyApp</item>
</style>

<style name="PopupMenu.MyApp" parent="@android:style/Widget.Holo.ListPopupWindow">
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_MyApp</item> 

</style>

<style name="DropDownListView.MyApp" parent="@android:style/Widget.Holo.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_MyApp</item>

</style>

<style name="ActionBarTabStyle.MyApp" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_MyApp</item>

    <item name="background">@drawable/tab_indicator_ab_MyApp</item>
</style>

<style name="DropDownNav.MyApp" parent="@android:style/Widget.Holo.Spinner">
    <item name="android:background">@drawable/spinner_background_ab_MyApp</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_MyApp</item>
    <item name="android:dropDownSelector">@drawable/selectable_background_MyApp</item>

    <item name="background">@drawable/spinner_background_ab_MyApp</item>
</style>

<style name="ProgressBar.MyApp" parent="@android:style/Widget.Holo.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/progress_horizontal_MyApp</item>

</style>

<style name="ActionButton.CloseMode.MyApp" parent="@android:style/Widget.Holo.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_MyApp</item>

    <item name="background">@drawable/btn_cab_done_MyApp</item>
</style>

</resources>
4

1 回答 1

1

根据官方文档,您还需要声明没有命名空间的属性android:。在您的情况下,这些属性仅应用于本机实现。

于 2013-08-02T23:03:48.353 回答