Search...

Sunday, November 13, 2011

How to change the Spinner item default look and feel in android


Step1: create new xml for your spinner item.

e.g: my_spinner_item.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="11dp"
    android:paddingBottom="11dp"
    android:paddingLeft="23dp" android:textAppearance="@style/sans17white">
</TextView>

Step2: Use your xml to create adapter for the spinner view.

ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(
this,R.layout.my_spinner_item, myOptions);
adapter.setDropDownViewResource(R.layout.my_spinner_item);

mySpinner.setAdapter(adapter);

No comments:

Post a Comment