Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Word Wrap in an Android Multi-Line TextView

I am working on a Month View with an advanced swipe (requires current, next and previous to be loaded to allow each view to stick to your finger) which means I have many views which causes things to be a little bit slow.

            |          | #<-- screen bounderies
 ' previous ' current  '   next   ' #<-- three months loaded
    ' previous ' current  '   next   ' #<-- three months when the user drags their finger

Because of this I want to represent multiple events in a single TextView. When the user taps one of the days on the Month View (small screen), it will open the day view for that day.

On each day in the month view (typically a single day gets one seventh of the width of the screen and a little less than one seventh vertically) I would like to avoid this

|    31|
|10a:  |
| Testi|
|ng    |
|11a:  |

Instead I want

|    31|
|10a:  |
| Testi|
|11a:  |
| Anoth|

Notice that the ng is cut off instead of wrapping to the next line. This is what I am looking for.

like image 414
700 Software Avatar asked Feb 28 '11 18:02

700 Software


People also ask

What is disable text wrap?

When text wrapping is enabled for a control, text will automatically wrap inside that control when users type into it. If text wrapping is disabled, any text that exceeds the width of the control will be hidden. You can also change the way that text wraps around picture controls on the form template.

Which tag is used to turn off the word wrapping?

Word Wrapping Netscape includes two tags: <NOBR>... </NOBR>, and <WBR>. The former turns off wordwrapping between the start and end NOBR tag, while WBR is for the rare case when you want to specify where to break the line if needed.

How do I turn off word wrap in sublime?

To disable Word Wrap in Sublime Text 3, you need to click on “View” in the top bar, then untick “Word Wrap”. This will completely disable the Word Wrapping feature. Click on “View” in the top bar, then untick “Word Wrap”.


2 Answers

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.

like image 66
Derrick Avatar answered Sep 25 '22 02:09

Derrick


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

like image 35
auwall Avatar answered Sep 26 '22 02:09

auwall