If I call getMeasuredWidth() or getWidth() for layout in onResume they return 0

前端 未结 7 2043
深忆病人
深忆病人 2020-11-28 09:10

If I call getMeasuredWidth() or getWidth() for layout in onResume they returns 0. I think that view it\'s not drawn yet in this moment.

Also I think that I need to

7条回答
  •  日久生厌
    2020-11-28 10:01

    Use below code:

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
       super.onWindowFocusChanged(hasFocus);
       Log.e("WIDTH",""+view.getWidth());
       Log.e("HEIGHT",""+view.getHeight());
    }
    

提交回复
热议问题