我有猫动画跳跃,它有 5 个可绘制对象,我想触摸猫并让它跳跃。
如果 android oneshot="false",则在触摸猫后它会一直跳下去。
<?xml version="1.0" encoding="utf-8"?>
<item android:drawable="@drawable/cat1" android:duration="250"></item>
<item android:drawable="@drawable/cat2" android:duration="250"></item>
<item android:drawable="@drawable/cat3" android:duration="250"></item>
<item android:drawable="@drawable/cat4" android:duration="250"></item>
<item android:drawable="@drawable/cat5" android:duration="250"></item>
<item android:drawable="@drawable/cat1" android:duration="250"></item>
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.page5);
cat_jump = (ImageView)findViewById(R.id.cat_jump);
cat_jump.setBackgroundResource(R.drawable.cat_jumping_animation);
final AnimationDrawable frameAnimation = (AnimationDrawable) cat_jump.getBackground();
cat_jump.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
frameAnimation.start();
}
});