首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Frame Animation帧播发动画

2012-09-21 
Frame Animation帧播放动画?xml version1.0 encodingutf-8?animation-listandroid:id@+id/hand

Frame Animation帧播放动画

<?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();

?

如果用Tween??Aniamation动画 你的用

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 楼 jasonlhm 2012-04-17   Handler handler = new Handler();
handler.postDelayed(new Runnable() {

@Override
public void run() {
// TODO Auto-generated method stub
_animaition.start();
}
}, 50);

在oncreate加上这个就可以了

热点排行