2012-03-26 2 views
0

J'ai un problème avec la commutation d'images dans Android. Je veux créer une animation où quand je clique sur l'image il tourne à 360 et quand il est à moitié, cela signifie que l'image 180 est allumée sur l'autre. L'image est dans imageView et j'ai la méthode onClick. A ce moment, lorsque je clique sur l'image, j'allume les autres et après que l'animation commence. Je veux changer d'image avec d'autres lorsque l'animation dure 50%. Ceci est mon XML rotate:Android nad animation commutateur image

<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"  

    /> 

Comment puis-je changer l'image quand je commence l'animation? C'est possible?

Répondre

1

Peut-être essayer quelque chose comme ceci:

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){} 
}); 

mais si vous voulez modifier dans l'animation moitié, vous devriez avoir deux animations,

  • début animation +180 degrés
  • finition animation + 180 degrés