Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Honeycomb: How to style right corner arrow in spinner on an ActionBar

This is a pretty specific question. I have a spinner on an ActionBar that is added in the onCreate() method. I have been able to style the text white, but I can't get the underline and the triangle/arrow at the bottom right to appear as white. Here is my styling:

<item name="android:actionDropDownStyle">@style/customActionBarDropDownStyle</item>

<style name="customActionBarDropDownStyle" parent="android:style/Widget.Holo.Light.Spinner">
    <item name="android:textColor">#FFFFFF</item>
</style>

I can't find a style item/property that makes the underline and triangle white. Does one exists?

Here's an example. I have highlighted in red the triangle and underline that I want to make white.

enter image description here

like image 347
CACuzcatlan Avatar asked Sep 21 '11 23:09

CACuzcatlan


2 Answers

A bit late answer, but better than never :) You should create a new 9 patch drawable and set it as a background to android:actionDropDownStyle.

here is an example:

    <item name="android:actionDropDownStyle">@style/customActionBarDropDownStyle</item>
    <style name="customActionBarDropDownStyle"parent="android:style/Widget.Holo.Light.Spinner">
    <item name="android:background">@drawable/custom_spinner_dropdown</item>
    </style>

You can't set a color to almost every native component, as their backgrounds are (in most cases) 9-patch pngs.

like image 195
dimlah Avatar answered Nov 14 '22 14:11

dimlah


The actionDropDownStyle can not used to change the style of spinner you added on actionbar; its for one of the actionbar mode ActionBar.NAVIGATION_MODE_LIST;

As for your problem, you can define a selector for your spinner in the layout file,just like this:

enter code here
<Spinner
    android:dropDownWidth="200dp"
    android:background="@drawable/actionbar_spinner"
    android:id="@+id/action_spinner"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginRight="10dp" />
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false"
        android:drawable="@drawable/spinner_ab_disabled" />
    <item android:state_pressed="true"
        android:drawable="@drawable/spinner_ab_pressed" />
    <item android:state_pressed="false" android:state_focused="true"
        android:drawable="@drawable/spinner_ab_focused" />
    <item android:drawable="@drawable/spinner_ab_default" />
</selector>
like image 22
sweetvvck Avatar answered Nov 14 '22 14:11

sweetvvck