Hello!

I have a spinner containing long lines. Is it possible to display the selected line truncated? That is, I select a long line from the list, and in a closed spinner, the selected line is displayed shortened.

Thank you in advance!

  • 3
    set the maximum TextView length, which serves as a list item for the spinner. - Vladyslav Matviienko
  • it starts outputting in a few lines - SlowAR
  • 3
    Attributes android:singleLine , android:maxLines , android:ellipsize to help you. - Helisia
  • one
    @SlowAR, then, as @metalurgus said, apply these attributes to> TextView, which serves as a list item for a spinner. In extreme cases, the adapter can be hardcored string trimming. - Helisia
  • one
    @SlowAR, these attributes are in TextView, which is a list item for Spinner. - Vladyslav Matviienko

1 answer 1

Add the following lines to your spinner (a) markup:

 android:ellipsize="end" android:maxLines="1" 

Description:

  • maxLines - strictly indicates how many lines will be in the widget
  • ellipsize - cuts the string if it does not interfere in one line and put "..." at the end

I hope you helped my decision!