开发者

Customize an android spinner

开发者 https://www.devze.com 2023-03-18 04:24 出处:网络
I m trying to customize a spinner so that it has a image as selector instead of radio buttons(default). I am referring to this blog. But it doesnt seem to work. Any suggestions on how to proceed or li

I m trying to customize a spinner so that it has a image as selector instead of radio buttons(default). I am referring to this blog. But it doesnt seem to work. Any suggestions on how to proceed or link to a tutorial would also be great. i get the following errors:

No resource identifier found for attribute 'spinnerSelector' in package 'android'

No resource found that matches the given name (at 'drawable' with value '@drawable/btn_dropdown_down

'

 <Spinner android:layout_width="match_parent"
                        android:layout_height="wrap_content" android:text=""
                        android:layout_alignParentRig开发者_Python百科ht="true" android:id="@+id/spinnerCompletedStatus" android:spinnerSelector="@drawable/myspinner_selector"
                         android:drawSelectorOnTop="true"  />

Thanks


Looking at the native Spinner style:

<style name="Widget.Spinner">
<item name="android:background">@android:drawable/btn_dropdown</item>
<item name="android:clickable">true</item>
<item name="android:spinnerMode">dialog</item>
<item name="android:dropDownSelector"> @android:drawable/list_selector_background</item>
<item name="android:popupBackground"> @android:drawable/spinner_dropdown_background</item>
<item name="android:dropDownVerticalOffset">-10dip</item>
<item name="android:dropDownHorizontalOffset">0dip</item>
<item name="android:dropDownWidth">wrap_content</item>
<item name="android:popupPromptView">@android:layout/simple_dropdown_hint</item>
<item name="android:gravity">center</item>
</style>

and then at drawable/btn_dropdown, drawable/list_selector_background, drawable/spinner_dropdown_background files -> you can come to a conclusion that you need: - btn_dropdown*.png - list_selector_background*.png - spinner_dropdown_background*.png files, from all the folders like drawable-ldpi, drawable-mdpi etc. And then add your xml style to your project.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号