我想旋轉一個ImageView圖像。這裏是我的代碼:ImageView旋轉而不重新創建位圖
Matrix mat = new Matrix();
mat.preRotate(90, ivImage.getWidth()/2, ivImage.getHeight()/2);
ivImage.setScaleType(ScaleType.MATRIX);
ivImage.setImageMatrix(mat);
,但是當我點擊旋轉按鈕,不僅圖像旋轉,但它是按比例也是如此,因爲位圖是較大的,則ImageView
。
我知道我可以使用
b = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), mat, true);
ivImage.setImageBitmap(b);
但這明顯變慢,並且具有一定的滯後性。
所以我的問題是:如何旋轉圖像而不被縮放和重新創建位圖?
這太好了,但是當圖像旋轉到90度時,圖像被切割,整個圖像不可見,它將超出圖像視圖的邊界。任何解決方案? – nikmin
@nikmin你可以請附上該圖像的屏幕截圖 – kamil
我認爲當視圖旋轉時,您的linearlayout寬度或高度不可調整。 – kamil