Skip to content Skip to sidebar Skip to footer

Android Holo Theme Does Not Wrap Multiple Line Spinner Dropdown Items

I recently just implemented the holo theme into my android app. After doing this, any spinner that I have, where the drop down item is multiple lines long, will not wrap the text

Solution 1:

As i had mentioned in : Spinner does not wrap text -- is this an Android bug?

I think there is a bug on android. You could try this. Remove the spaces from the text and then display it would work fine. If the length of the textview is < that of the string, it ignores all the characters after the space. For a work-around you could try this :

add a file to res/layout folder named multiline_spinner_dropdown_item.xml with the sample code:

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"android:id="@android:id/sample_text"
style="?android:attr/spinnerDropDownItemStyle"android:singleLine="false"android:layout_width="match_parent"android:layout_height="?android:attr/listPreferredItemHeight"android:ellipsize="marquee" />

and when you are creating the spinner create it from this layout.

Something like :

ArrayAdapter.createFromResource(this, items, R.layout.multiline_spinner_dropdown_item);

Basically, copy the android.R.layout.simple_spinner_dropdown_item layout into the project and modify the layout by setting singleLine attribute to false in CheckedTextView.

Post a Comment for "Android Holo Theme Does Not Wrap Multiple Line Spinner Dropdown Items"