开发者

TextView doesn't wrap text correctly after resize

开发者 https://www.devze.com 2023-04-02 13:44 出处:网络
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 recalcula

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

精彩评论

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