Why setting text from onMeasure does not affect TextView?

前端 未结 7 1206
走了就别回头了
走了就别回头了 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条回答
  •  不要未来只要你来
    2021-01-13 12:56

    From the View documentation page.

    Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

    If you want the textview to have limited width or height call setMaxWidth() setMaxHeight() setMaxLines() or check it manualy and change is the way you like from a custom method

提交回复
热议问题