Question

I want my ImageView roll from center of screen to right. I use this code at the moment, but it doesn't roll the image.

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);
Was it helpful?

Solution

try

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top