Why setting text from onMeasure does not affect TextView?

前端 未结 7 1135
走了就别回头了
走了就别回头了 2021-01-13 12:36

There is a TextView of a certain size and whenever text set to it is too long I\'d like to re-set it to some preset value.

To accomplish this I am overr

7条回答
  •  -上瘾入骨i
    2021-01-13 13:09

    onMeasure() is usually called during layout phase. Besides as far as I know onMeasure() is where YOU have to measure your view. It receives 2 values which are the size of the parent of your view which may be constant.

    Why don't you just check the length of the text you're setting and if it's too long just replace it with your default one?

提交回复
热议问题