1

the textView's height and width is fixed.

when the length of string is longer than textview,the last-line text sometimes display half.

I want,when the last-line text can't display complete,discard it.how to realize?

yava
  • 2,511
  • 3
  • 20
  • 17

1 Answers1

0

It sounds to me like you already have ellipsize enabled, and that's why you're only getting "half" the last line.

Depending on what you're trying to achieve, you can-

  • Remove ellipsize settings and suffer the string cut-off.
  • Resize your textview so that all the text will fit.
  • Change your font size so that all the text will fit.

StaticLayout has a way of detecting if the last line will cut off (using getEllipsisCount(line)) which is supposedly used internally by TextView, but I've had no luck using that to detect when a TextView is being cut off (see post).

If this doesn't help, please give us a better picture of what you're doing.

Community
  • 1
  • 1
Nathan Fig
  • 14,970
  • 9
  • 43
  • 57