开发者

TextView doesn't wrap text correctly after resize

I extended FrameLayout and overrode the onLayout() method. From there I call layout() on a TextView child to resize and relocate at will, but the wrapping of the text do开发者_JAVA百科esn't recalculate after the resize.

I've already tried setText() and setWidth().

Sure there is something I'm doing wrong. Any ideas?


You can give a try to autofittextview.


call setEllipsize(null) to recalculate the wrapping.


Building on Aladin Q's answer, this is what I used to handle pre ICS and ICS:

// pre ICS
if (Integer.parseInt(Build.VERSION.SDK) < 14) {
    setEllipsize(null);
// ICS and above
} else {
    setEllipsize(TruncateAt.END);
}


setEllipsize(null) will work well before "ICS" (Build.VERSION.SDK_INT < 14) but not after.

See this post for details.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜