Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to disable line wrap in a List View in android?

I have a list view holding text views and when the text gets too big, it wraps and the item takes up two spaces. I am wondering if there is a way to turn off line wrap in this case, and if it should be done in the textview or the listview.

like image 1000
NotACleverMan Avatar asked Feb 25 '23 23:02

NotACleverMan


2 Answers

Set android:singleLine attribute in TextView to true

like image 68
Denis Palnitsky Avatar answered Mar 19 '23 02:03

Denis Palnitsky


This is just a clarification (I don't have the reputation points to comment yet).

The XML item upon which you need to set the android:singleLine attribute is the one used for each individual item, not the ListView node (which doesn't support the android:singleLine attribute.

The individual item TextView is the one that you'd pass to the ArrayAdapter constructor used for the ListView.

like image 36
Robert Muil Avatar answered Mar 19 '23 01:03

Robert Muil