Reputation: 21
How do I change the text size of a spinner in android. I have read that if you get your items from a resource (like R.array.items) you use ArrayAdapter.createFromResource(context, R.array.items, R.layout.textview), but what if a get my items from a list that changes, how would I then change text size of the spinner.
Upvotes: 2
Views: 5430
Reputation: 16363
You need to redefine 2 resource xml's
Spinner spinner=new Spinner(context);
ArrayAdapter adapter = new ArrayAdapter(context, R.layout.my_spinner_item);
adapter.setDropDownViewResource(R.layout.my_spinner_dropdown_item);
E.g. my_spinner_dropdown_item.xml resource can be defined as:
<MyCheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/simpleSpinnerDropDownItem"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight" />
where MyCheckedTextView
class has to be defined by you (extending CheckedTextView
) - so it's a place where you can define your text size/style - whatever
Upvotes: 2