我正在使用RotateAnimation
来旋转图像。
但是我也希望在动画中对图像进行缩放。
也就是说,当我的图像旋转时,图像也在缩放...
如何在旋转动画中实现缩放?
在 anim xml 中,您可以像这样使用缩放:
<scale
android:pivotX="50%"
android:pivotY="50%"
android:fromXScale=".1"
android:fromYScale=".1"
android:toXScale="1.0"
android:toYScale="1.0"
android:duration="2000" />
ScaleAnimation scal=new ScaleAnimation(0, 1f, 0, 1f, Animation.RELATIVE_TO_SELF, (float)0.5,Animation.RELATIVE_TO_SELF, (float)0.5);
scal.setDuration(500);
scal.setFillAfter(true);
((ImageView)findViewById(R.id.logo)).setAnimation(scal);
AnimationSet animSet = new AnimationSet(false);
RotateAnimation rotate = new RotateAnimation(0, 180);
ScaleAnimation zoom = new ScaleAnimation(0, 0, 1, 1);
animSet.addAnimation(rotate);
animSet.addAnimation(zoom);
animSet.start();
您应根据您的应用程序需要更改参数。
animSet
动画添加到你的ImageView
(或其他你使用的View
)中。 - Pasha