![[android] 界面切换的简单动画,第1张 [android] 界面切换的简单动画,第1张](/aiimages/%5Bandroid%5D+%E7%95%8C%E9%9D%A2%E5%88%87%E6%8D%A2%E7%9A%84%E7%AE%80%E5%8D%95%E5%8A%A8%E7%94%BB.png)
1. 新建个位移动画的xml文件
Activity中开启动画
使用AnimationUtils类加载动画资源文件
left_to_right.xml
<?xml version="1.0" enCoding="utf-8"?><translate xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:fromXDelta="100%" androID:toXDelta="0" androID:duration="3000" ></translate>
VIEw child=new IndexVIEw(this).getMemberVIEw();child.startAnimation(AnimationUtils.loadAnimation(this,R.anim.left_to_right));
2. 淡入淡出动画
当前淡出界面和执行时间
淡出过程中,淡入界面处于等待状态
第二个界面淡入和他的执行时间
第一个界面执行完成后,要删除掉
package com.tsh.lottery.utils;import androID.support.v4.vIEw.VIEwPager; androID.vIEw.VIEw; androID.vIEw.VIEwGroup; androID.vIEw.VIEwParent; androID.vIEw.animation.AlphaAnimation; androID.vIEw.animation.Animation; androID.vIEw.animation.Animation.AnimationListener;public class FadeUtil { /** * 淡出界面 * @param vIEw 界面 * duration 执行时间 */ static voID fadeOut(final VIEw vIEw,long duration){ AlphaAnimation AlphaAnimation=new AlphaAnimation(1,0); AlphaAnimation.setDuration(duration); vIEw.startAnimation(AlphaAnimation); //监听动画结束,删除VIEw元素 AlphaAnimation.setAnimationListener(new AnimationListener() { @OverrIDe voID onAnimationStart(Animation animation) { } @OverrIDe onAnimationRepeat(Animation animation) { } @OverrIDe onAnimationEnd(Animation animation) { VIEwGroup vg=(VIEwGroup) vIEw.getParent(); vg.removeVIEw(vIEw); } }); } * 淡入界面 * delay 延迟时间 * voID fadeIn(VIEw vIEw,1)">long delay,1)">new AlphaAnimation(0,1); 设置开始时间延迟 AlphaAnimation.setStartOffset(delay); AlphaAnimation.setDuration(duration); vIEw.startAnimation(AlphaAnimation); }}
FadeUtil.fadeOut(child,2000);
FadeUtil.fadeIn(child,2000,2000);
总结
以上是内存溢出为你收集整理的[android] 界面切换的简单动画全部内容,希望文章能够帮你解决[android] 界面切换的简单动画所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)