/* * 通过这种方法获取image控件当前在手机里面显示出来的高度和宽度 ,也可以用来试试其他view*/
ViewTreeObserver vto = image.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
if (firstFlag == true) {
firstFlag = false;
imageOriginalHeight = image.getMeasuredHeight();
imageOriginalWidth = image.getMeasuredWidth();
System.out.println("imageHeight=" + imageOriginalHeight
+ " imageWidth==" + imageOriginalWidth);
}
}
});
网友评论