Android: Rotate image in imageview by an angle

前端 未结 25 2638
野趣味
野趣味 2020-11-22 06:35

I am using the following code to rotate a image in ImageView by an angle. Is there any simpler and less complex method available.

ImageView iv = (ImageView)f         


        
25条回答
  •  遇见更好的自我
    2020-11-22 07:03

    I know this is insanely late, but it was helpful for me so it may help others.

    As of API 11, you can set the absolute rotation of an ImageView programmatically by using the imageView.setRotation(angleInDegrees); method.

    By absolute, I mean you can repeatedly call this function without having to keep track of the current rotation. Meaning, if I rotate by passing 15F to the setRotation() method, and then call setRotation() again with 30F, the image's rotation with be 30 degrees, not 45 degrees.

    Note: This actually works for any subclass of the View object, not just ImageView.

提交回复
热议问题