0

在 ImageView 上实用地设置缩放动画时,我遇到了一些问题。基本上我有并且图像视图设置中心 H/V,但是当我应用动画时它会关闭它:(...Iv 读到枢轴 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);

在此处输入图像描述

4

1 回答 1

4

也许Animation.RELATIVE_TO_SELFAnimation.RELATIVE_TO_PARENT会做这项工作?例子:

new ScaleAnimation(1, 1.2f, 1, 1.2f,
            Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f));

将两者都视为0.5f50%,从左/上数

于 2014-12-11T21:18:37.583 回答