How do i change the color of the background where it says "add contact" and "about". Now its kind of grayish, but i want it to be white! This is a actionBar with dropdown, not a spinner. And im not using that actionbarsherlock thing.
问题:
回答1:
For example, in you exisiting parent Style
definition, add just the android:popupMenuStyle
attribute as shown below:
<style name="Theme.Example" parent="@android:style/Theme.Holo.Light">
<item name="android:popupMenuStyle">@style/PopupMenu.Example</item>
.......
.......
</style>
And override the android:popupMenuStyle
attribute by defining your style:
<style name="PopupMenu.Example" parent="@android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>
</style>
The @drawable/menu_dropdown_panel_example
is this:
You can either choose to use an image similar to the one above, or use an Color
resource.
And this is for the default ActionBar. Not the ActionBarSherlock
. ;-)
ActionBar
styles can be easily created using this cool website: http://jgilfelt.github.com/android-actionbarstylegenerator/. I usually experiment a little here before deciding on the style. Plus, it lets you download the styles and all necessary resources. Just plug them in your app and you are good to go. :-)
UPDATED: I think I caused some confusion which has resulted in the loss of the shadow on your app's drop-down. You may have replaced all the <items>
in your Style
that I listed in the original suggestion. The edit should fix that.
UPDATE 2:
Use these image resources instead of the @android:color/white
value you are currently using. These are in the order of XHDPI, HDPI and MDPI. Save them and use them in the Style definition.
回答2:
Try to get styles from ActionBarStyleGenerator service. It has preview and makes all necessary drawable, xml and styles. There you can easily find and change required color and then find it in sources (in your case it is android:popupBackground).
回答3:
You can simple override itemBackground item in your theme:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:itemBackground">@color/skyBlue</item>
</style>