edwin
edwin

Reputation: 1252

TextView no wrapping special character Android

Is there a way to create/override the custom word wrap engine for Android TextView?

For example,

My name is Edwin (US:1113)

Should be displayed as

My name is Edwin

(US:1113)

Instead of

My name is Edwin (US:

1113)

Already tried changing all the possible value for the setting below but nothing good.

Android:maxLines
Android:setHorizontallyScrolling
Android:ellipsize
Android:singleLine

In my findings, word wrap in TextView does not include special characters such as :.

Updated 3.09AM 2/7/2018 UTC

As mentioned by @Umair, line breaking with "\n" is not possible because I don't know the length of the text before the colon :. This will line break the sentence too early before it reached the maximum width of the TextView.

Upvotes: 2

Views: 333

Answers (1)

user8959091
user8959091

Reputation:

Use 2 TextViews inside a LinearLayout with horizontal orientation and put My name is Edwin in the 1st and (US:1113) in the 2nd. If there is no space for the 2nd TextView then it will fall to the next line.

Upvotes: 2

Related Questions