简体   繁体   中英

Custom Style of ActionBar is ignored (doesn't work)

I'm attempting to style the ActionBar. I created my custom style in values folder. No errors found. I ran my application and it worked fine. However, my custom style doesn't work and I don't know why. I did all changes exactly that I wanted.

I have declared Activity theme in manifest android:theme="@style/Theme.AndroidDevelopers"

When I run it, the application appears with a ugly action bar (background gray, popup menu gray and text black...the default blue scheme) - it has nothing to do with my custom style:

    <?xml version="1.0" encoding="utf-8"?>
      <resources>
      <style name="Theme.AndroidDevelopers" parent="android:style/Theme.Holo.Light">
      <item name="android:selectableItemBackground">@drawable/ab_item_background</item>
      <item name="android:popupMenuStyle">@style/MyPopupMenu</item>
      <item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
      <item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
      <item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
      <item name="android:listChoiceIndicatorMultiple">@color/amarelo</item>
      <item name="android:listChoiceIndicatorSingle">@color/vermelho</item>
  </style>

<!-- style the list navigation -->
<style name="MyDropDownNav" parent="android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@color/vermelho</item>
<item name="android:popupBackground">@color/orange</item>
<item name="android:dropDownSelector">@drawable/seletor2</item>
    </style>

<!-- style for the tabs -->
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@color/verdeclaro</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
 </style>

  <!-- style the overflow menu -->
 <style name="MyPopupMenu" parent="android:style/Widget.Holo.Light.ListPopupWindow">
 <item name="android:popupBackground">@color/branco</item> 
 </style>

 <!-- style the items within the overflow menu -->
 <style name="MyDropDownListView" parent="android:style/Widget.Holo.ListView.DropDown">
 <item name="android:listSelector">@drawable/seletor2</item>
 </style>

 <style name="MyActionBar" parent="android:style/Widget.Holo.Light.ActionBar">
 <item name="android:background">@drawable/actionbarbackground</item>
 </style>
 </resources>`

Use the appcompat style.

Here is a good tutorial: https://guides.codepath.com/android/Using-the-App-ToolBar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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