[ACCEPTED]-Disable Word Wrap in an Android Multi-Line TextView-nowrap

Accepted answer
Score: 45

In Java:

setHorizontallyScrolling(boolean) 

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

Score: 18

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

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

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

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

Score: 2

Currently the best answer for XML is

android:maxLines="1"

Because 1 android:singleLine is now depreciated

More Related questions