android 在Activity的OnCreate()方法中如何获取view的宽和高

来源:互联网 发布:安徽人工智能学会 编辑:程序博客网 时间:2024/06/02 17:00
final CustomView custom_view = (CustomView) findViewById(R.id.custom_view);
custom_view.measure(0, 0);
custom_view.post(new Runnable() {
@Override
public void run() {
int width= custom_view.getMeasuredWidth();
int height = custom_view.getMeasuredHeight();
Log.e(TAG, "width="+width);
Log.e(TAG, "height="+height);
}

});

没啥好解释的

0 0
原创粉丝点击