【发布时间】:2014-05-23 05:08:40
【问题描述】:
我读到的所有内容都表明您不能在构造函数中的 View 上调用 getWidth() 或 getHeight(),但我在 onResume() 中调用它们。到时候屏幕的布局不应该已经画好了?
@Override
protected void onResume() {
super.onResume();
populateData();
}
private void populateData() {
LinearLayout test = (LinearLayout) findViewById(R.id.myview);
double widthpx = test.getWidth();
}
【问题讨论】:
标签: android android-layout android-view activity-lifecycle android-viewtreeobserver