Android:按角度旋轉圖像視圖中的圖像 - Android: Rotate image in imageview by an angle

問題:

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章