Android中的属性动画(一般属性动画,组合属性动画,AnimatorSet,动画监听)
2016-05-31 22:10
627 查看
设置属性动画
组合属性动画
AnimatorSet随意定制动画
动画监听(两种监听)
自由落体
《Android版本更新、热更新》系列课程视频
版本更新6.0,7.0统统搞定!!
热修复不在麻烦,再也不用担心上线后出bug!!
http://edu.csdn.net/course/detail/6523
http://edu.csdn.net/course/play/6523/131198
《Kotlin语法基础到实战开发》系列课程视频
http://edu.csdn.net/course/detail/6409?locationNum=7&fps=1&ref=srch&loc=1
http://edu.csdn.net/course/play/6409/123752
public void Click(View view){ //f是float类型 ObjectAnimator.ofFloat(view, "retainX", 0.0f,360.0f).setDuration(500).start(); }
组合属性动画
public void doclickt(View view){ PropertyValuesHolder pl=PropertyValuesHolder.ofFloat("alpha", 1f,0f,1f); PropertyValuesHolder p2=PropertyValuesHolder.ofFloat("sclatex", 1f,0f,1f); ObjectAnimator.ofPropertyValuesHolder(view, pl,p2).setDuration(500).start(); }
AnimatorSet随意定制动画
ObjectAnimator a1=ObjectAnimator.ofFloat(view, "translationX", 0f,200f); ObjectAnimator a2=ObjectAnimator.ofFloat(view, "translationY", 0f,200f); ObjectAnimator a3=ObjectAnimator.ofFloat(view, "translation", 0f,200f); AnimatorSet set=new AnimatorSet(); set.setDuration(100); //set.playTogether(a1,a2,a3);//同时执行 //set.setStartDelay(100);//延迟执行 //set.playSequentially(a1,a2,a3);//顺序执行 set.play(a1).with(a2);//a1,a2同时执行,之后执行a3 set.play(a3).after(a2); set.start();
动画监听(两种监听)
public void startAnimtor(View view){ ObjectAnimator animator = ObjectAnimator.ofFloat(view, "alpha", 1f,0f).setDuration(100); animator.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator arg0) { // 开始动画 } @Override public void onAnimationRepeat(Animator arg0) { // 重复动画 } @Override public void onAnimationEnd(Animator arg0) { // 结束动画 } @Override public void onAnimationCancel(Animator arg0) { // 取消动画 } }); animator.start(); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // TODO Auto-generated method stub super.onAnimationEnd(animation); } }); animator.start(); }
自由落体
public void onClick(View view){ final View v=view; DisplayMetrics bm=new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(bm); //自由落体(第一个参数是起点,第二个是运动到的位置,第三是返回原位(不写下去就不上来领)) ValueAnimator duration = ValueAnimator.ofFloat(view.getY(),bm.heightPixels,v.getY()).setDuration(500); //监听动画的每个动作 duration.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator an) { // TODO Auto-generated method stub v.setTranslationY((Float) an.getAnimatedValue()); } }); duration.start(); }
《Android版本更新、热更新》系列课程视频
版本更新6.0,7.0统统搞定!!
热修复不在麻烦,再也不用担心上线后出bug!!
http://edu.csdn.net/course/detail/6523
http://edu.csdn.net/course/play/6523/131198
《Kotlin语法基础到实战开发》系列课程视频
http://edu.csdn.net/course/detail/6409?locationNum=7&fps=1&ref=srch&loc=1
http://edu.csdn.net/course/play/6409/123752
相关文章推荐
- android greenDAO
- Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found
- Android图片缓存之Bitmap详解(一)
- android R文件
- android make debug : (.ARM.exidx+0x0): error: undefined reference to '__aeabi_unwind_cpp_pr1'
- android布局属性
- Android--ScrollView中嵌套使用ListView
- Android多媒体__信息和简单的音乐播放
- Android加载/处理超大图片神器!SubsamplingScaleImageView(subsampling-scale-image-view)【系列1】
- Android__数据存储
- android布局属性详解
- Android中常用的5大布局方式
- ThreadLocal及在Android中的应用
- android studio虚拟机启动报错
- Unable to execute dex: Multiple dex files define Lcom/xj/util/R$drawable
- 动态添加Fragments
- android自定义View浅析
- Android_通知(Notification)
- Android__Service
- android下的callback机制