根据我所阅读的资料,你不能在构造函数中调用getWidth()
或getHeight()
方法来获取View
的宽度或高度,但是我在onResume()
方法中调用了这些方法。此时屏幕布局难道不应该已经绘制好了吗?
@Override
protected void onResume() {
super.onResume();
populateData();
}
private void populateData() {
LinearLayout test = (LinearLayout) findViewById(R.id.myview);
double widthpx = test.getWidth();
}