// 在 onResume() 回调中获取宽高
Log.e(“measure”,“measure in onResume: width= w i n d o w . d e c o r V i e w . w i d t h , h e i g h t = {window.decorView.width}, height= window.decorView.width,height={window.decorView.height}”)
}
}
大多数人都能直截了当的给出答案:
E/measure: measure in onCreate: width=0, height=0
E/measure: measure in onResume: width=0, height=0
E/measure: measure in View.post: width=1080, height=2340
在 onCreate()
和 onResume()
中是无法获取到宽高的,而 View.post()
回调中可以。从日志打印顺序可以看出来&#x