問題:
I am using the following code to rotate a image in ImageView by an angle.我正在使用以下代碼將 ImageView 中的圖像旋轉一個角度。 Is there any simpler and less complex method available.是否有任何更簡單和更簡單的方法可用。
ImageView iv = (ImageView)findViewById(imageviewid);
TextView tv = (TextView)findViewById(txtViewsid);
Matrix mat = new Matrix();
Bitmap bMap = BitmapFactory.decodeResource(getResources(),imageid);
mat.postRotate(Integer.parseInt(degree));===>angle to be rotated
Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0,bMap.getWidth(),bMap.getHeight(), mat, true);
iv.setImageBitmap(bMapRotate);
解決方案:
參考一: https://en.stackoom.com/question/bgaT參考二: https://stackoom.com/question/bgaT