Rotate ImageView source from layout xml file

前端 未结 3 2079
南笙
南笙 2021-02-06 20:53

I have this ImageView in my layout:



        
3条回答
  •  青春惊慌失措
    2021-02-06 21:44

    You can do that in your code by creating a new bitmap object. Check this out : http://android-er.blogspot.fr/2010/07/rotate-bitmap-image-using-matrix.html And specifically this function

    Matrix matrix = new Matrix();
    matrix.postScale(curScale, curScale);
    matrix.postRotate(curRotate);
    
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, true);
    myImageView.setImageBitmap(resizedBitmap);
    

提交回复
热议问题