安卓Android中如何设置图片的移动,能够自动地移动,比如下雨的情形,雨滴自由下落
图片移动就用动画就可以啊,在Activity的onStart()或者onResume()中启动动画,你每次进入Activity,这个图片就会自动的移动的。
http://www.2cto.com/kf/201109/102541.html
protected void onResume() {
super.onResume();
/** 设置位移动画 向右位移150 */
final TranslateAnimation animation = new TranslateAnimation(0, 150,150, 0);
animation.setDuration(10000);//设置动画持续时间
animation.setRepeatCount(20);//设置重复次数
animation.setRepeatMode(Animation.REVERSE);//设置反方向执行
image01.setAnimation(animation);
image02.setAnimation(animation);
/** 开始动画 */
animation.startNow();
/** 结束动画 */
//animation.cancel();
}
就是在onresume中启动动画就能够实现图片的移动效果