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

前端 未结 7 2026
深忆病人
深忆病人 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 09:55

    Simpler way:

    view.post(new Runnable() {
        public void run() {
            view.getWidth();
        }
    }
    );
    

    http://developer.android.com/reference/android/view/View.html#post(java.lang.Runnable)

提交回复
热议问题