1

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 doesn't recalculate after the resize.

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

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

Amanda S
  • 3,266
  • 4
  • 33
  • 45
slipbull
  • 1,477
  • 1
  • 11
  • 27
  • I didn't get you. You want to set the height and width of textview according to your requirement???? – RiksAndroid Sep 06 '11 at 12:18
  • you can use onpredrawlistner to set width of the textview. I think it will work. Set the width inside the predrawlistner according to you. – RiksAndroid Sep 07 '11 at 11:22

4 Answers4

1

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);
}
Community
  • 1
  • 1
bmaupin
  • 14,427
  • 5
  • 89
  • 94
1

You can give a try to autofittextview.

Vins
  • 8,849
  • 4
  • 33
  • 53
1

call setEllipsize(null) to recalculate the wrapping.

slipbull
  • 1,477
  • 1
  • 11
  • 27
0

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

See this post for details.

Community
  • 1
  • 1
Aladin Q
  • 550
  • 5
  • 12