Reputation: 10685
I am using the xml
in my layout
folder to declare my spinners. For example:
<Spinner
android:id="@+id/foo_spinner"
android:layout_width="0sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="30sp" />
I load the spinner entries within my code. My problem is that the text size isn't affected. I can put 100sp
there but nothing will happen. Do I have to change it only after I load the spinner content? Do I need to do this after every time I update the content?
Upvotes: 0
Views: 1184
Reputation: 9700
If you want to customize the text size Spinner
item then you will have to use custom layout from Spinner
item.
Suppose, create an custom TextView
layout for Spinner
item named custom_spinner_item.xml
as follows...
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="30sp" />
Now, use this layout XML to show your spinner items like:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.custom_spinner_item, list);
Another thing, you should use dp
or dip
instead of sp
for android:layout_width
attribute and android:textSize
isn't appropriate for Spinner
element.
<Spinner
android:id="@+id/foo_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
Upvotes: 2