edi233
edi233

Reputation: 3031

Android nad animation switch image

I have a problem with switching images in android. I want to create animation where when I click on the picture he rotate 360 and when he is in half, that mean 180 picture is switch on other. Image is in imageView and I have onClick method. At this time when I click on picture picture switch on other and after that animation is starting. I want to image change with other when I animation is 50% in duration. This is my rotate XML:

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:shareInterpolator="false">
<rotate
 android:fromDegrees="0"
 android:toDegrees="360"
 android:pivotX="100%"
 android:duration="1000"    

    />

how Can I switch image when i start animation? This is possible?

Upvotes: 0

Views: 625

Answers (1)

goodm
goodm

Reputation: 7295

Maybe try something like this:

ImageView img = (ImageView)findViewById(R.id.XXXXXX);
img.startAnimation(a);
Animation a = AnimationUtils.loadAnimation(this, "your animation");
a.setAnimationListener(new AnimationListener()
{
@Override
public void onAnimationEnd(Animation animation)
{
    // change image here img.setImage....
}

@Override
public void onAnimationStart(Animation animation){}
@Override
public void onAnimationRepeat(Animation animation){}
});

but if you want to change this in half animation you should have two animations,

  • start animation +180 degrees
  • finish animation + 180 degrees

Upvotes: 1

Related Questions