Disable Word Wrap in an Android Multi-Line TextView Disable Word Wrap in an Android Multi-Line TextView android android

Disable Word Wrap in an Android Multi-Line TextView


In Java:

setHorizontallyScrolling(boolean) 

In theory, android:scrollHorizontally should do the same in XML, but there is a bug in android that stops it working.


android:singleLine-----this is for xml

setTransformationMethod(TransformationMethod)-----this is for java

Constrains the text to a single horizontally scrolling line instead of letting it wrap onto multiple lines, and advances focus instead of inserting a newline when you press the enter key.

I'm not sure if this will work, but it worked for me when I wanted my TextView not to wrap in my ListView


Currently the best answer for XML is

android:maxLines="1"

Because android:singleLine is now depreciated