繁体   English   中英

适用于Android ActionBar的style.xml

[英]style.xml for android ActionBar

我为我的androidActionBar创建了styl.xml和所需的.png文件。 这是style.xml:

<resources>

    <style name="Theme.Example" parent="@android:style/Theme.Holo.Light">
        <item name="android:actionBarItemBackground">@drawable/ab_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_background_textured_example</item>
        <item name="android:backgroundStacked">@drawable/ab_stacked_solid_example</item>
        <item name="android:backgroundSplit">@drawable/ab_background_textured_example</item>
        <item name="android:progressBarStyle">@style/ProgressBar.Example</item>
    </style>

    <style name="ActionBar.Transparent.Example" parent="@android:style/Widget.Holo.Light.ActionBar">
        <item name="android:background">@drawable/ab_transparent_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/ab_selectable_background_example</item>
    </style>

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

    <style name="DropDownNav.Example" parent="@android:style/Widget.Holo.Light.Spinner">
        <item name="android:background">@drawable/ab_spinner_background_ab_example</item>
        <item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>
        <item name="android:dropDownSelector">@drawable/ab_selectable_background_example</item>
    </style>

    <style name="ProgressBar.Example" parent="@android:style/Widget.Holo.Light.ProgressBar.Horizontal">
        <item name="android:progressDrawable">@drawable/ab_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_default_example</item>
    </style>

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

</resources>

现在,如果我转到androidManifest并更改

android:theme="@style/Theme.AppCompat.Light.DarkActionBar"

变成:

android:theme="@style/Theme.Example"

我的应用程序从一开始就崩溃了:S是否有可能我某种程度上需要一个AppCompat主题,因为我使用了

import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;

对此我不确定。 如果我做该如何解决,因为我想给ActionBar一个不同的颜色和一个height属性。

还是应该删除ActionBar并使用新的工具栏。 我不确定我是否可以使用它,因为它来自新的Material Design,并且仅适用于Lolipop及更高的产品?

寻求帮助

请尝试将您的THeme声明替换为以下内容。

取代这个

<style name="Theme.Example" parent="@android:style/Theme.Holo.Light">

有了这个

 <style name="Theme.Example" parent="@style/Theme.AppCompat.Light"> 

您可能需要在项目中添加Android支持库v7。

将每个Holo替换为AppCompat 我的意思是,在您找到Holo的每一行中,将其替换为AppCompat

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM