1

我希望我的ImageView滚动从屏幕中心向右。我目前使用此代码,但它不会滚动图像。

final AnimationSet rollingIn = new AnimationSet(true);

Animation moving = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, -1f, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0,
    Animation.RELATIVE_TO_PARENT, 0);
moving.setDuration(5000);

rollingIn.addAnimation(moving);
4

1 回答 1

2

尝试

final AnimationSet rollingIn = new AnimationSet(true);
    Animation moving = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 5, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
    moving.setDuration(1000);
    final Animation rotating = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotating.setDuration(1000);

    rollingIn.addAnimation(rotating);
    rollingIn.addAnimation(moving);
于 2014-01-23T08:04:53.480 回答