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

后端 未结 4 1383
遥遥无期
遥遥无期 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:15

    Short method

    View.animate().rotation(90).setDuration(0);

    0 讨论(0)
  • 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);
    }
    
    0 讨论(0)
  • 2020-12-31 19:29

    did you try to use a custom view extending imageview and rotating the image in a background thread?

    0 讨论(0)
  • 2020-12-31 19:35

    You don't need to rotate the object, rotating the view should be enough. If you are aiming API>=11 you can always do this.

    mImageView.setRotation(angle);
    

    Cheers.

    0 讨论(0)
提交回复
热议问题