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

落花浮王杯 提交于 2019-11-30 09:16:55

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);
}

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.

Short method

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!