Android 属性动画ObjectAnimator使用demo,组合动画
生活随笔
收集整理的這篇文章主要介紹了
Android 属性动画ObjectAnimator使用demo,组合动画
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//第一個參數:指定執行動畫的控件,第二個參數:指定控件的屬性,第三個參數是可變長參數
public static ObjectAnimator ofFloat(Object target, String propertyName, float... values)
動畫過程監聽
animator2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {@Overridepublic void onAnimationUpdate(ValueAnimator valueAnimator) {float value = (float) valueAnimator.getAnimatedValue();Log.i("lgq",":ssss====="+value);//動畫過程監聽} });動畫狀態監聽
animator2.addListener(new Animator.AnimatorListener() {@Overridepublic void onAnimationStart(Animator animator) {Log.i("lgq",":ssss===onAnimationStart=111=");}@Overridepublic void onAnimationEnd(Animator animator) {Log.i("lgq",":ssss===onAnimationEnd==222");animator2.setAutoCancel(false);}@Overridepublic void onAnimationCancel(Animator animator) {Log.i("lgq",":ssss===onAnimationCancel=333=");animator.cancel();}@Overridepublic void onAnimationRepeat(Animator animator) {Log.i("lgq",":ssss===onAnimationRepeat=444=");} });動畫暫停
animator.pause();動畫重新開始
animator.resume();動畫重復次數
animator2.setRepeatCount(1);組合動畫方法:
AnimatorSet set = new AnimatorSet(); set.play(animator).with(animator3).with(animator2); set.start(); //透明度動畫 ObjectAnimator animator = ObjectAnimator.ofFloat(view,"alpha",1,0,1); animator.setDuration(2000); animator.start(); //旋轉動畫:圍繞x軸旋轉 ObjectAnimator animator = ObjectAnimator.ofFloat(tv,"rotationX",0,270,0); animator.setDuration(2000); animator.start();//旋轉動畫:圍繞y軸旋轉 ObjectAnimator animator = ObjectAnimator.ofFloat(tv,"rotationY",0,180,0); animator.setDuration(2000); animator.start();//旋轉動畫:圍繞z軸旋轉 ObjectAnimator animator = ObjectAnimator.ofFloat(tv,"rotation",0,270,0); animator.setDuration(2000); animator.start(); //平移動畫:在x軸上平移 ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "translationX", 0, 200, -200,0); animator.setDuration(2000); animator.start(); //平移動畫:在y軸上平移 ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "translationY", 0, 200, -100,0); animator.setDuration(2000); animator.start(); //縮放動畫:在x軸縮放 ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "scaleX", 0, 3, 1); animator.setDuration(2000); animator.start();//縮放動畫:在y軸上縮放 ObjectAnimator animator = ObjectAnimator.ofFloat(tv, "scaleY", 0, 3, 1); animator.setDuration(2000); animator.start();總結
以上是生活随笔為你收集整理的Android 属性动画ObjectAnimator使用demo,组合动画的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 折叠头部监听,抽屉式动画
- 下一篇: Android获取手机联系人或通讯录的基