public class AndroidAnim extends Activity {
/** Called when the activity is first created. */
boolean b=false;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final ImageView imageView1 = (ImageView) findViewById(R.id.ImageView1);
final ImageView imageView2 = (ImageView) findViewById(R.id.ImageView2);
final AnimationDrawable myAnimation1;
imageView1.setBackgroundResource(R.drawable.loadinganim);
imageView2.setBackgroundResource(R.drawable.loadinganim);
myAnimation1 = (AnimationDrawable) imageView1.getBackground();
imageView2.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
for(int i=0;i<20;i++){
myAnimation1.start();
imageView2.startAnimation(AnimationUtils.loadAnimation(getBaseContext(), R.anim.effect_in));
}
}
});
} } 我使用此代码尝试移动2 ImageView。当我点击屏幕时,我想要一个接一个地移动ImageView(第一次移动imageView1,之后必须移动imageView2) 对不起我的英语不好。
答案 0 :(得分:0)
也许AnimationListener可以帮到你吗?
实施它:
implements SurfaceHolder.Callback, AnimationListener {
设置动画:
Animation effectIn;
// in onCreate()
effectIn = AnimationUtils.loadAnimation(this, R.anim.effect_in);
effectIn.setAnimationListener(this);
当一个动画结束时,你会触发另一个动画:
@Override
public void onAnimationEnd(Animation animation) {
if(animation == effectIn){
// start effectOut or whatever.
}
如果您希望动画保持/停止它们的结束方式,请使用:
effectIn.setFillAfter(true);
或者用XML声明:
android:fillEnabled="true"
android:fillAfter="true"
希望这有帮助!