簡體   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