我希望在结束动画后再次重新启动imageview动画。 我的代码下面不会启动事件我调用translate1();在animate()。withEndAction()。
任何人都可以帮我这个吗?
@SuppressLint("NewApi")
public void translate1()
{
ant_play_1 = (ImageView) findViewById(R.id.ant_play_1); ant_play_1.setBackgroundResource(R.drawable.walking_play_1);
ant_play_1.setVisibility(View.VISIBLE);
ant_play_1.setX(40);
walking_1 = (AnimationDrawable) ant_play_1.getBackground(); walking_1.start(); //translate1();
ant_play_1.animate().setDuration(15000);
ant_play_1.animate().translationY(300);
ant_play_1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
//Toast.makeText(play_1.this, "Hello I am here", Toast.LENGTH_SHORT).show();
walking_1.stop();
ant_play_1.animate().cancel();
ant_play_1.setEnabled(false);
ant_play_1.setBackgroundResource(R.drawable.ant_smashed);
}
});
ant_play_1.animate().withEndAction(new Runnable() {
@Override
public void run() {
translate1();
}
});