Android开发获取ImageView显示的图片尺寸
生活随笔
收集整理的這篇文章主要介紹了
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);}}
總結
以上是生活随笔為你收集整理的Android开发获取ImageView显示的图片尺寸的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何成为一个全能的机器人工程师
- 下一篇: 截止2022年4月10日,unity5.