简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM