//图片切换
public Runnable runnable = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
//俩个动画
AnimationSet animationSet1 = new AnimationSet(true);
AnimationSet animationSet2 = new AnimationSet(true);
//设置imageView2 为可见
img_ayout_2.setVisibility(0);
TranslateAnimation ta = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, -1f,
Animation.RELATIVE_TO_SELF,0f,
Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f);
//设置动画持续时间
ta.setDuration(10000);
//放入动画
animationSet1.addAnimation(ta);
//动画充满
animationSet1.setFillAfter(true);
ta = new TranslateAnimation(
Animation.RELATIVE_TO_SELF,0f,
Animation.RELATIVE_TO_SELF, 1.0f,
Animation.RELATIVE_TO_SELF,0f,
Animation.RELATIVE_TO_SELF, 0f);
ta.setDuration(10000);
animationSet2.addAnimation(ta);
animationSet2.setFillAfter(true);
// 开始执行
img_ayout_1.startAnimation(animationSet1);
img_ayout_2.startAnimation(animationSet2);
if (juage){
handler.postDelayed(runnable,8000);
}
}
};
调用:开始----》handler.postDelayed(runnable, 0);
暂停------>handler.removeCallbacks(runnable);