How to style spinner prompt?

痴心易碎 提交于 2019-12-11 07:02:46

问题


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



来源:https://stackoverflow.com/questions/5500908/how-to-style-spinner-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!