测量View宽度和高度

来源:互联网 发布:软件技术服务招聘 编辑:程序博客网 时间:2024/05/23 19:24

原文地址:http://www.2cto.com/kf/201410/341592.html
注意:原文的第一种方法是不能测量match_parent类型的宽度和高度的下面这种方法是可以得,所以推荐使用这种方法。

ViewTreeObserver vto = imageView.getViewTreeObserver();           vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {             @Override              public void onGlobalLayout() {                 imageView.getViewTreeObserver().removeGlobalOnLayoutListener(this);                 imageView.getHeight();                imageView.getWidth();            }           });
0 0
原创粉丝点击