为了账号安全,请及时绑定邮箱和手机立即绑定

浅谈Android动画

难度中级
时长31分
学习人数
综合评分9.60
146人评价 查看评价
9.8 内容实用
9.5 简洁易懂
9.5 逻辑清晰
  • 逐帧动画“FrameAnimation” 1. 在Drawable文件夹下定义animation-list.xml <animation-list xmlns:android="http://schemas.android.com/apk/res/android" > <!-- 按顺序排列 drawable指定一张图片 duration指定每张图片停留的时间 --> <item android:drawable="@drawable/one" android:duration="500"/> <item android:drawable="@drawable/six" android:duration="500"/> <item android:drawable="@drawable/three" android:duration="500"/> <item android:drawable="@drawable/two" android:duration="500"/> </animation-list> 2.为ImageView设置资源 mImageView.setImageResource(R.drawable.anim_list); //设置图片资源即可。
    查看全部
  • 布局动画“举例,listView使用LayoutAnimation” Animation animation=AnimationUtils.loadAnimation(this, R.anim.zoom_in); LayoutAnimationController controller=new LayoutAnimationController(animation); controller.setOrder(LayoutAnimationController.ORDER_NORMAL);//设置显示顺序,具体看源码 listView.setLayoutAnimation(controller);//将控制器设置给listView listView.startLayoutAnimation();//开始布局动画
    查看全部
  • 组合动画四“Activity切换时的动画” Intent intent=new Intent(MainActivity.this, SecondActivity.class); startActivity(intent); //注意:要在startActivity之后使用overridePendingTransition,否则无效 overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out);//分别是进入时的动画,和退出时的动画
    查看全部
  • 组合动画“使用设置重复,来进行动画重复播放。” AlphaAnimation alphaAnimation=new AlphaAnimation(0.1f, 1f);//使用代码动态增加动画。 alphaAnimation.setDuration(1000); alphaAnimation.setRepeatCount(2); //设置重复次数 alphaAnimation.setRepeatMode(Animation.REVERSE); //reverse代表倒序重复,restart表示正序重复 mImageView.startAnimation(alphaAnimation); 其中,reverse和restart。 /** * When the animation reaches the end and the repeat count is INFINTE_REPEAT * or a positive value, the animation restarts from the beginning. */ public static final int RESTART = 1; /** * When the animation reaches the end and the repeat count is INFINTE_REPEAT * or a positive value, the animation plays backward (and then forward again). */ public static final int REVERSE = 2;
    查看全部
  • 组合动画二“在xml文件中配置连续动画” <set xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 渐变动画,表示从透明度10%到100%,持续时间为1秒 --> <alpha android:fromAlpha="0.1" android:toAlpha="1" android:duration="1000" > </alpha> <!-- *在一个文件中定义两个动画,则两个动画都会执行 *android:startOffset="1000" 动画延迟执行的毫秒数。此时表示动画在1s之后执行。配合上面的动画实现动画连续播放效果。 --> <alpha android:fromAlpha="1" android:toAlpha="0.1" android:startOffset="1000" android:duration="1000" > </alpha> </set>
    查看全部
  • 组合动画一“使用动画监听器实现” animation=AnimationUtils.loadAnimation(this, R.anim.alpha); mImageView.startAnimation(animation); animation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { animation=AnimationUtils.loadAnimation(MainActivity.this, R.anim.rotate); mImageView.startAnimation(animation); } });
    查看全部
  • RotateAnimation(旋转动画) <set xmlns:android="http://schemas.android.com/apk/res/android"> <!-- android:fromDegrees="0" 表示从0度开始旋转 android:toDegrees="-720" 表示“逆时针”旋转两圈(720度),如果是“+720”,则为顺时针旋转720度 --> <rotate android:fromDegrees="0" android:toDegrees="-720" android:pivotX="0" android:pivotY="0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:duration="2000" > </rotate> </set>
    查看全部
  • TranslateAnimation(位移动画) <set xmlns:android="http://schemas.android.com/apk/res/android"> <!-- android:fromXDelta="0" //表示从x哪个位置开始,如果是0,就是当前位置 android:toXDelta="100" //表示到x哪个位置结束 Delta 【数学】(变量的)增量 --> <translate android:fromXDelta="0" android:toXDelta="100" android:fromYDelta="0" android:toYDelta="100" android:duration="1000" ></translate> </set>
    查看全部
  • ScaleAnimation(缩放动画) xml文件 <set xmlns:android="http://schemas.android.com/apk/res/android" > <!-- interpolator //插入器,比如这个设置是先加速,后减速。 android:pivotX="0.1" 设置锚点x的坐标。表示从该坐标开始放大 --> <scale android:duration="1000" android:fromXScale="1" android:fromYScale="0.1" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="0.1" android:pivotY="50%" android:toXScale="1.0" android:toYScale="1.0" > </scale> </set>
    查看全部
  • AlphaAnimation(透明动画) 1.xml文件 <set xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 渐变动画,表示从透明度10%到100%,持续时间为1秒 --> <alpha android:fromAlpha="0.1" android:toAlpha="1" android:duration="1000" > </alpha> </set> 2.代码 Animation animation;//动画对象 animation=AnimationUtils.loadAnimation(this, R.anim.alpha); //将动画加载进来 mImageView.startAnimation(animation);//imageView开始动画,参数为设置好的动画
    查看全部
  • 动画-19
    查看全部
  • 动画-18
    查看全部
  • 动画-17
    查看全部
  • 动画-16
    查看全部
  • 动画-15
    查看全部

举报

0/150
提交
取消
课程须知
本课程为基础课程: 1.基本掌握Android基础相关知识。 2.熟练掌握布局文件xml的使用 3.灵活应用xml中各个属性的用途
老师告诉你能学到什么?
1.动画效果概览 2.四种基础动画实现 3.各种特效实例的实现

微信扫码,参与3人拼团

意见反馈 帮助中心 APP下载
官方微信
友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!