繁体   English   中英

在Android中进行翻译时如何让imageview旋转?

[英]How do I get an imageview to rotate while translating in Android?

我正在尝试制作一个在屏幕上滑动时旋转的imageview。 我设置了一个180度的旋转动画,它自己工作。 我设置了一个翻译动画,它自己工作。 当我将它们组合在一起时,我会得到一个形成大螺旋的imageview。 我希望imageview在翻译时围绕imageview的中心旋转。

        AnimationSet animSet = new AnimationSet(true);
        //Translate upwards and to the right.   
        TranslateAnimation anim =
            new TranslateAnimation(
                    Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, +80.0f,
                    Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, -100.0f
                    );
            anim.setInterpolator(new DecelerateInterpolator()); 
            anim.setDuration(400);
            animSet.addAnimation(anim);

            //Rotate around center of Imageview
            RotateAnimation ranim = new RotateAnimation(0f, 180f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); //, 200, 200); // canvas.getWidth() / 2, canvas.getHeight() / 2);
            ranim.setDuration(400);
            ranim.setInterpolator(new DecelerateInterpolator());

            animSet.addAnimation(ranim);

            imageBottom.startAnimation(animSet);

好吧,我想我“橡皮鸭”这个。

动画的应用顺序很重要。 我将订单从翻译/旋转切换到旋转/翻译,它的工作原理。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM