How to style spinner prompt?

2019-08-14 16:29发布

问题:

I have successfully styled spinner background like here: How to set font custom font to Spinner text programmatically?

My opened spinner looks like this:

Only thing that is left to style is spinner prompt box (and text inside). How can i change background color and font of spinner prompt?

EDIT:Based on 2red13 advice i created style:

<?xml version="1.0" encoding="utf-8"?>
 <resources>
<style name="spinner_style">                        
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:textColor">#00FF00</item>
    <item name="android:typeface">monospace</item>
    <item name="android:background">#8b4513</item>
</style>

and aplied it to spinner like this:

 <Spinner 
    android:id="@+id/spinner"
     style="@style/spinner_style"   
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:prompt="@string/header_prompt"
    android:background="@drawable/spinaca" 
    android:layout_margin="5dip"/>  

But nothing has changed. I guess i don't understand something :(

回答1:

the style is defined here:

style="?android:attr/spinnerItemStyle"

you have to build your own style and set it instaed of the above