旋转后的ImageView会恢复到原来的状态? [英] ImageView will reset to original state after rotating?

查看:1469
本文介绍了旋转后的ImageView会恢复到原来的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/3882826/android-animation-position-resets-after-complete">Android:动画位置复位完成后

我用 RotateAnimation 旋转的的ImageView 。在code是简单的:

I'm using RotateAnimation to rotate an ImageView. The code is simple:

this.button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Animation ani = new RotateAnimation(
                0, /* from degree*/
                30, /* to degree */
                Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        ani.setDuration(1000);
        imageView.startAnimation(ani);
    }
});

您可以看到我想要的ImageView的旋转30度。

You can see I want the imageView rotate 30 degree.

它的工作原理,但是当完成转动时,图像返回到原来的状态,在同一位置和度旋转之前。 我想解决的ImageView最后动画的位置,即要修复30度倾斜的图像。 如何解决这个问题?

It works, but when rotating is done, the image go back to the original state, the same position and degree before rotating. I want to fix ImageView at last Animation position i.e want to fix the image tilted by 30 degree. How to fix it?

推荐答案

我刚刚找到一个解决办法:

I just find an solution:

ani.setFillAfter(true);

它的工作原理:)

It works :)

这篇关于旋转后的ImageView会恢复到原来的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆