Why setting text from onMeasure does not affect TextView?

前端 未结 7 1230
走了就别回头了
走了就别回头了 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:53

    In your onMeasure(int,int)

    1. CALL super(int,int)
    2. Use getMeasuredWidth() and getMeasuredHeight

    something like this:

    void onMeasure(int a, int b){
        super(a,b);
        if(getMeasuredWidth()>bla)
            setText("default");
    }
    

提交回复
热议问题