简体   繁体   English

适用于Android ActionBar的style.xml

[英]style.xml for android ActionBar

i made a styl.xml and the needed .png files for my androidActionBar. 我为我的androidActionBar创建了styl.xml和所需的.png文件。 here is the style.xml: 这是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>

now if i go to my androidManifest and change the 现在,如果我转到androidManifest并更改

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

into: 变成:

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

my app crashes right from the start :S is it possible that i somehow need a AppCompat theme because i use 我的应用程序从一开始就崩溃了:S是否有可能我某种程度上需要一个AppCompat主题,因为我使用了

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

im not sure about that. 对此我不确定。 If i do how could i fix it since i want to give my ActionBar a different color and a height attribute. 如果我做该如何解决,因为我想给ActionBar一个不同的颜色和一个height属性。

or should i remove the ActionBar and use the new Toolbar. 还是应该删除ActionBar并使用新的工具栏。 Im not sure if i can use that though since its from the new Material Design and is only for Lolipop and higher right? 我不确定我是否可以使用它,因为它来自新的Material Design,并且仅适用于Lolipop及更高的产品?

thx for the help 寻求帮助

try replacing your THeme declaration with below one. 请尝试将您的THeme声明替换为以下内容。

Replace this 取代这个

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

With this 有了这个

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

you might ned to add Android Support library v7 in your project. 您可能需要在项目中添加Android支持库v7。

Replace every Holo with AppCompat . 将每个Holo替换为AppCompat I mean in every line where ever you find Holo replace it with AppCompat 我的意思是,在您找到Holo的每一行中,将其替换为AppCompat

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

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