How to style spinner prompt?

2019-08-14 16:37发布

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

My opened spinner looks like this:

enter image description here

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条回答
Fickle 薄情
2楼-- · 2019-08-14 17:24

the style is defined here:

style="?android:attr/spinnerItemStyle"

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

查看更多
登录 后发表回答