Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text Size of a Spinner

How can I decrease the font size of my spinner? I have reduced the spinner size to 35 pix because of which my text gets cut in half.

How do i do that? Also I dont want anything to be selected beforehand.

Default text should be "select some value".

like image 495
NickHalden Avatar asked Jul 25 '10 13:07

NickHalden


2 Answers

after some tests, there is an easier way than subclassing ArrayAdapter. Change the

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.planets_array,android.R.layout.simple_spinner_item);//this is from the tutorial, adapt with your line

to this line :

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.planets_array, R.layout.textview);

You just have to change the design of the TextView you use of the Spinner. I just tried with this, as the layout of the textview.xml :

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:text="@+id/TextView01" android:id="@+id/TextView01"
android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="30sp"></TextView>
like image 68
Sephy Avatar answered Oct 31 '22 03:10

Sephy


Changing

ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.planets_array,android.R.layout.simple_spinner_item);

to ArrayAdapter.createFromResource(this, R.array.planets_array, R.layout.textview);

will change only the item which is visible by default on the spinner. If we need the same style to be applied on all the items in the spinner, we need to change

adapter.setDropDownViewResource(android.R.layout.simple_spinner_item)   to 


adapter.setDropDownViewResource(R.layout.textview);
like image 26
Sora Avatar answered Oct 31 '22 03:10

Sora