Android: Rotate image in ImageView by 90degrees but without delay

后端 未结 4 1419
遥遥无期
遥遥无期 2020-12-31 18:59

I am developing a game where a user needs to tap on the image in ImageView to rotate it. On each tap image rotates by 90 degrees in clockwise direction. But image is taking

4条回答
  •  长情又很酷
    2020-12-31 19:24

    I also tried to do it once and couldn't find any other solution but using animation. Here how I'd do.

    private void rotate(float degree) {
        final RotateAnimation rotateAnim = new RotateAnimation(0.0f, degree,
                RotateAnimation.RELATIVE_TO_SELF, 0.5f,
                RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    
        rotateAnim.setDuration(0);
        rotateAnim.setFillAfter(true);
        imgview.startAnimation(rotateAnim);
    }
    

提交回复
热议问题