Why does LinearLayout child getWidth method return 0?

前端 未结 3 1595
死守一世寂寞
死守一世寂寞 2020-12-07 04:08

I have a LinearLayout, and this LinearLayout will hold dynamically placed views. I need to find out what the width of the children of LinearLayout, however this has to be do

3条回答
  •  悲&欢浪女
    2020-12-07 04:54

    You might be able to get with the below. But as others pointed out, this probably isn't a great idea.

    LinearLayout.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    LinearLayout.getMeasuredWidth();
    

提交回复
热议问题