<?xml version="1.0" encoding="utf-8"?><animation-list   android:id="@+id/handimation" android:oneshot="false"      xmlns:android="http://schemas.android.com/apk/res/android">     <item android:drawable="@drawable/a1" android:duration="150" />     <item android:drawable="@drawable/icon" android:duration="150" />     <item android:drawable="@drawable/stat_sad" android:duration="150" />  </animation-list>

将上面的代码加入res/anim/rocket_thrust.xml

然后在代码中:

ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);      rocketImage.setBackgroundDrawable(getResources().getDrawable(R.drawable.rocket_thrust));      rocketAnimation = (AnimationDrawable) rocketImage.getBackground();

或者

rocketImage.setBackgroundResource(R.anim.rocket_thrust);
rocketAnimation = (AnimationDrawable) rocketImage.getBackground();

如果用TweenAniamation动画 你的用

rocketImage.setAnimation(AnimationUtils.loadAnimation(this, R.anim.rocket_thrust) );

同时还要注意 你的图画不能是黑白的 这样看不出效果,因为屏幕是黑色的 我就因为这个原因 还以为代码错误

然后就是运动

@Override  public boolean onTouchEvent(MotionEvent event) {    if (event.getAction() == MotionEvent.ACTION_DOWN) {    ((AnimationDrawable) rocketAnimation).start();    return true;    }    return super.onTouchEvent(event);    }

在这里没有弄出自动播放 我也没找到原因

更多相关文章

  1. Android 代码改变图片颜色android:tint="@color/main_color" and
  2. Kotlin 写 Android 单元测试(四),Robolectric 在 JVM 上测试安卓相
  3. 修改 framework 代码的经验和踩过的坑
  4. android常用颜色代码定义
  5. android 代码proguard
  6. Android日志系统分析之日志设备驱动程序代码阅读

随机推荐

  1. tools for working with android jni
  2. android GPS DEMO
  3. Android(安卓)沿着线绘制文字
  4. Android(安卓)导入项目出错
  5. Android(安卓)背光流程小结
  6. android 开发之Activity切换
  7. Android(安卓)简单视图
  8. Android与服务器通信的方法之一-->TCP
  9. Android(安卓)TimePicker example
  10. Android学习札记18:Drawable中的setDither