Android Custom Spinner (background, font color)

Source: Internet
Author: User

1, prepare two pictures, and do 9.png

650) this.width=650; "Name=" image_operate_50101341392844221 "title=" Android <wbr> custom <wbr>spinner < wbr> (background, font color) "alt=" Android <wbr> custom <wbr>spinner <wbr> (background, font color) "src=" http://s1.sinaimg.cn/ middle/3e333c4axc3fd5b1bb340&690 "/>


2. Define spinner_selector.xml in drawable

<?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"/>< effect!--Press

<item android:state_pressed= "false"

android:drawable= "@drawable/spinner"/><!--default Effect--

</selector>


3. defined in style

<!--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"

Android:drawselectorontop= "true"/>



5. Define simple_spinner_item.xml in Layout

<?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:gravity= "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> (mcontext, r.layout.simple_spinner_item );

String level[] = getresources (). Getstringarray (R.array.affair_level);//resource file

for (int i = 0; i < level.length; i++) {

Adapter.add (Level[i]);

}

Adapter.setdropdownviewresource (Android. R.layout.simple_spinner_dropdown_item);

Spinner.setadapter (adapter);


650) this.width=650; "Name=" image_operate_19871341393403270 "width=" 461 "height=" "title=" Android <wbr> Custom <wbr>spinner <wbr> (background, font color) "alt=" Android <wbr> custom <wbr>spinner <wbr> (background, font color) "src=" http://s2.sinaimg.cn/middle/3e333c4axc3fd61ad0ab1&690 "/>

650) this.width=650; "Name=" image_operate_56181341393403695 "title=" Android <wbr> custom <wbr>spinner < wbr> (background, font color) "alt=" Android <wbr> custom <wbr>spinner <wbr> (background, font color) "src=" http://s11.sinaimg.cn/ middle/3e333c4axc3fd644b385a&690 "/>



This article is from "Little book" blog, please make sure to keep this source http://8988940.blog.51cto.com/8978940/1579376

Android Custom Spinner (background, font color)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.