Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent line-break in TextView

In my Android app I have a text view that displays text containing special characters. The TextView somehow automatically breaks strings at the characters '/' and '-'.

For example, the string "aaaaaaa/bbb-ccccc/ddd" is displayed as

aaaaaaa/
bbb-
ccccc/
ddd

However, I would like to display it without any linebreaks except the one at the boundaries of the view, i.e., like this:

aaaaaaa/bb
bb-ccccc/d
dd

Is there any way to deactivate the automatic line-breaks or to escape these characters? I already tried escaping with \uFEFF without success.

like image 289
user3190568 Avatar asked Jan 13 '14 14:01

user3190568


1 Answers

Keep your textview attribute

android:layout_width="wrap_content"
android:layout_height="wrap_content"

Define Your string in string.xml

<string name="Username"> aaaaaaa\/bb\nbb\-ccccc\/d\ndd</string>
like image 177
megha jagdale Avatar answered Oct 12 '22 17:10

megha jagdale