标签:
直接用view.getheightMesure获取不到(因为还没绘制出来)
用这个
int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); imageView.measure(w, h); int height = imageView.getMeasuredHeight(); int width = imageView.getMeasuredWidth();
或者
ViewTreeObserver vto = imageView.getViewTreeObserver(); vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { vto.removeOnPreDrawListener(this); int height = imageView.getMeasuredHeight(); int width = imageView.getMeasuredWidth(); return true; } });
标签:
原文地址:http://www.cnblogs.com/luogang/p/4568822.html