measuring a view before rendering it

后端 未结 5 1140
傲寒
傲寒 2020-11-29 01:37

I need to find out how big a view will be after attaching it to its parent.

I have overridden this method:

onMeasure(int, int);

but

5条回答
  •  [愿得一人]
    2020-11-29 01:52

    first call

     view.measure(0, 0);
    

    then get

    view.getMeasuredWidth() or view.getMeasuredHeight()

提交回复
热议问题