Click here to Skip to main content
15,886,792 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a spinner with very long text that is populated from a database. I have a custom layout for the dropdown here:

Multiline_spinner_dropdown.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:singleLine="false"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textSize="38sp"
    android:ellipsize="marquee"
    android:padding="8dp"
    android:removed="@drawable/gradient_spinner_popup" />


Here is my spinner in my layout:

<Spinner
    style="@style/spinnerstyle1080dp"
    android:id="@+id/Spinner4"
    android:layout_width="match_parent"
    android:layout_height="98dp"
    android:layout_centerVertical="true"
    android:layout_below="@+id/View4"
    android:popupremoved="@android:color/transparent"
    android:spinnerMode="dropdown"
    android:dropDownVerticalOffset="0dp"
    android:dropDownWidth="fill_parent" />


If I remove
android:spinnerMode="dropdown"
from my spinner in my layout then the text wraps like it should but the spinner dropdown pops up as a dialog which is not what I want.

How can I have
android:spinnerMode="dropdown"
and have the text wrap when it is too long for a screen to display?
Posted
Updated 13-Aug-20 21:41pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900