开发者

TextView subclass doesn't wrap words

开发者 https://www.devze.com 2023-03-05 07:45 出处:网络
I\'m subclassing TextView in a class named Message and adding instances of this class into a ListView. The problem is that if the text the user sets on the Message class is too wide, the v开发者_如何学

I'm subclassing TextView in a class named Message and adding instances of this class into a ListView. The problem is that if the text the user sets on the Message class is too wide, the v开发者_如何学JAVAiew doesn't wrap words as expected.

What should I do?


There are a couple of things I suspect need to be done:

  1. setSingleLine to false (sounds like you should do it in the constructor of Message).
  2. Make sure the layout_height of the widget you're placing in the ListView is WRAP_CONTENT (but not the layout_width!)

You can also play with setMinLines and setLines if it better suits your needs.

0

精彩评论

暂无评论...
验证码 换一张
取 消