Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change font size on actual Spinner button object

I know it is possible to change the font size of the Spinner menu that pops up when the button is clicked, and I know it is possible to change the font size of an ordinary button - but I can't seem to find anything on changing the size of the text in the actual spinner button itself. Is this possible? If so, how can it be done?

like image 288
dharris001 Avatar asked Jan 15 '23 16:01

dharris001


1 Answers

This is the generic layout from simple_spinner_item.xml, I've added a textSize attribute at the bottom, let's save it as spinner_item.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee"
    android:singleLine="true" 
    android:textSize="36sp" />

And you use it just like any other layout in an adapter:

Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.spinner_dropdown_item);
spinner.setAdapter(adapter);
like image 122
Sam Avatar answered Jan 22 '23 14:01

Sam