Turn from: HTTP://BLOG.SINA.COM.CN/S/BLOG_3E333C4A010151CJ.HTML1, prepare two pictures, and do 9.png
2, defined in the drawableSpinner_selector.xml<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_pressed=" true "android:drawable=" @drawable/spinner_press "/><!--Press Time Effects-<item android:state_pressed= "false" android:drawable= "@drawable/spinner"/><!--default effect--> ; </selector> 3, style definition <!--spinner---<style name= "Spinner_style"> <item name=" Android:background ">@drawable/spinner_selector</item> <item name= "Android:paddingleft" >5dip</item> </style> 4, call <spinner Android:id = "@+id/field_item_spinner_content" style= "@style/spinner_style"Android:layout_width=" fill_parent "android:layout_height=" Wrap_content "android:animationcache=" true "Androi D:drawselectorontop= "true"/> 5, defined in layoutSimple_spinner_item.xml<?xml version= "1.0" encoding= "Utf-8"? ><checkedtextview xmlns:android= "Http://schemas.android.com/apk/res /android "android:id=" @android: Id/text1 "android:paddingleft=" 5dip "android:paddingright=" 5dip "Android:gravi Ty= "center_vertical" android:textcolor= "#808080" android:singleline= "true" android:layout_width= "Fill_parent" android:layout_height= "Wrap_content"/> 6, Java code arrayadapter<string> adapter = new arrayadapter<string& gt; (Mcontext,R.layout.simple_spinner_item); String level[] = getresources (). Getstringarray (R.array.affair_level);//resource file for (int i = 0; i < level.length; i++) {ADAP Ter.add (Level[i]);} Adapter.setdropdownviewresource (Android. R.layout.simple_spinner_dropdown_item); Spinner.setadapter (adapter);
Android Custom Spinner (background, font color)