Roadblock
Roadblock

Reputation: 2071

TextView wrapping issue

I was looking through the functionalities provided with the TextView and was starting to wonder how TextView handles wrapping. So, I created a few layouts employing TextViews, which raised questions regarding the implementation of TextView.

When I create a TextView with width and height set to wrap_content and I insert all space characters as text, the view expands to accomodate the space. But this does only happens as long as it is on single line. Once the first line of textView get filled, it doesnot expand to include second/more lines for space characters, but the next character that I insert gets printed on the second line without any starting space.

The question here is, If I want to detect where the end of the characters happen for textView and create a different layout as per the space available, on the same line or different line of textView.

I would appreciate if I can get some generic solution, related to this. I would appreciate if someone can tell me how to override the existing textView to define my own wrapping system.

Upvotes: 1

Views: 142

Answers (1)

Roadblock
Roadblock

Reputation: 2071

I figured out that adding space is not enough to create a wrap, but if you concatenate the string with   it works. Maybe it has something similar to the the non breakable space (nbsp) in HTML. The following stackoverflow question gave me an insight into this. whatsapp-message-layout

Upvotes: 1

Related Questions