1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > Android开发获取ImageView显示的图片尺寸

Android开发获取ImageView显示的图片尺寸

时间:2024-03-16 19:37:28

相关推荐

Android开发获取ImageView显示的图片尺寸

private ImageView imageView;private int realImgShowWidth, realImgShowHeight;private void getImgDisplaySize() {Drawable imgDrawable = imageView.getDrawable();if (imgDrawable != null) {//获得ImageView中Image的真实宽高,int dw = mCurrentImage.getDrawable().getBounds().width();int dh = mCurrentImage.getDrawable().getBounds().height();//获得ImageView中Image的变换矩阵Matrix m = mCurrentImage.getImageMatrix();float[] values = new float[10];m.getValues(values);//Image在绘制过程中的变换矩阵,从中获得x和y方向的缩放系数float sx = values[0];float sy = values[4];//计算Image在屏幕上实际绘制的宽高realImgShowWidth = (int) (dw * sx);realImgShowHeight = (int) (dh * sy);}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。