在ImageView上实用地设置Scale动画时,我遇到了一些问题。 基本上我有和图像视图设置中心H / V,但当我应用动画时,它设置它:(...我读到关于枢轴x / y设置为50%,但它似乎不起作用,任何反馈将太棒了......下面的屏幕截图
AnimationSet set = new AnimationSet(true);
Animation animation = new ScaleAnimation(1, 1.2f, 1, 1.2f, Animation.ABSOLUTE, 50, Animation.ABSOLUTE, 50);
animation.setDuration(500);
animation.setRepeatCount(-1);
animation.setRepeatMode(Animation.RESTART);
set.addAnimation(animation);
animation = new ScaleAnimation(1.2f, 1.4f, 1.2f, 1.4f, Animation.ABSOLUTE, 50, Animation.ABSOLUTE, 50);
animation.setDuration(500);
animation.setRepeatCount(-1);
animation.setRepeatMode(Animation.RESTART);
set.addAnimation(animation);
animation = new ScaleAnimation(1.4f, 1.0f, 1.4f, 1.0f, Animation.ABSOLUTE, 50, Animation.ABSOLUTE, 50);
animation.setDuration(500);
animation.setRepeatCount(-1);
animation.setRepeatMode(Animation.RESTART);
set.addAnimation(animation);
image_view.startAnimation(set);
答案 0 :(得分:3)
也许Animation.RELATIVE_TO_SELF
或Animation.RELATIVE_TO_PARENT
可以完成这项工作吗?例如:
new ScaleAnimation(1, 1.2f, 1, 1.2f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f));
将0.5f
视为50%,从左/上计算