-
ObjectaAnimator.ofFloat(imageView,"translationX",0f,200f).setDuration(1000).start(); 屬性: translationX 偏移量 translationY X 絕對值 rotation 多個動畫同時進行(start(),異步進行) PropertyValuesHolder pl = PropertyValuesHolder.ofFloat("rotation",0,360); PropertyValuesHolder p2 = PropertyValuesHolder.ofFloat("rotation",0,360); ObjectAnimator.ofPropertyValuesHolder(imageView,p1,p2).setDuration(1000).start(); AnimatorSet aset = new AnimationSet(); ObjectAnimator a1 = ObjectAnimator.ofFloat(ImageView,"rotaton",0,200f); ObjectAnimator a2 = ObjectAnimator.ofFloat(ImageView,"rotaton",0,200f); ObjectAnimator a3 = ObjectAnimator.ofFloat(ImageView,"rotaton",0,200f); aset.playTogether(a1,a2,a3); aset.playDuration(1000); aset.start(); aset.playSequentially();//按順序執行動畫 aset.start(); aset.play(a1).with(a2); aset.play(a2).after(a2); aset.start();查看全部
-
ObjectAnimator animator = ObjectAnimator.ofFloat(view,"alpha",0,1f).setDuration(1000); animator.addListener(new Animator.AnimatorListener() { public void onAnimationStart(Animator animation) { } public void onAnimationEnd(Animator animation) { } public void onAnimationCancel(Animator animation) { } public void onAnimationRepeat(Animator animation) { } }); //選擇監聽事件 animator.addListener(new AnimatorListenerAdapter(){ }); //差值器(均速度,加速度,拋物線)內置九種差值器 animator,setInterpolator(new BounceInterpolator());查看全部
-
動畫屬性記錄查看全部
-
為動畫增加監聽事件 animitor.addListenner(new Animator);查看全部
-
先左右平移 再旋轉 別哭 我親愛的人查看全部
-
動畫集合 幾個動畫放一塊 同時執行 別哭 我親愛的人查看全部
-
別哭 我親愛的人查看全部
-
留作備用查看全部
-
Animation只能改變Ui顯示而不能改變控件實際位置,不適合做有交互得動畫效果查看全部
-
常用屬性查看全部
-
·先截張圖,明天繼續,跑步去~查看全部
-
·使用AnimatorSet來完成 { AnimatorSet set = new AnimatorSet(); ObjectAnimator animator1 = ObjectAnimator.offloat(imageView, "rotation", 0f, 200f); ObjectAnimator animator2 = ObjectAnimator.offloat(imageView, "translationX", 0f, 200f); ObjectAnimator animator3 = ObjectAnimator.offloat(imageView, "translationY", 0f, 200f); set.playTogether(animator1,animator2,animator3); // 動畫一起播放 // set.playSequentially(animator1,animator2,animator3); // 順序播放動畫 // 控制動畫之間的播放順序 // set.play(animator2).with(animator3); // 先X和Y一起平移 // set.play(animator1).after(animator3); // 平移完成之后旋轉 set.setDuration(1000); set.start(); }查看全部
-
// 這里是指偏移量 ·ObjectAnimator.offloat(imageView, "translationX", 0f, 200f).setDuration(1000).start(); ·ObjectAnimator.offloat(imageView, "translationY", 0f, 200f).setDuration(1000).start(); // 這里是指絕對位置 ·ObjectAnimator.offloat(imageView, "X", 0f, 200f).setDuration(1000).start(); ·ObjectAnimator.offloat(imageView, "Y", 0f, 200f).setDuration(1000).start(); // 旋轉 ·ObjectAnimator.offloat(imageView, "rotation", 0f, 360f).setDuration(1000).start(); // 只要屬性具有Getter和Setter方法,就可以使用屬性動畫 ·可以多條語句,最后會一起執行(start方法是異步執行的) ·也可以通過PropertyValuesHolder來完成組合屬性動畫 { PropertyValuesHolder pvh1 = PropertyValuesHolder.offloat("rotation", 0, 360F); PropertyValuesHolder pvh2 = PropertyValuesHolder.offloat("X", 0f, 200f); PropertyValuesHolder pvh3 = PropertyValuesHolder.offloat("Y", 0f, 200f); ObjectAnimator.offPropertyValuesHodler(imageView, pvh1, pvh2, pvh3).setDuration(1000).start(); } -> 另外Google對PropertyValuesHolder對動畫進行了優化查看全部
-
·Android 3.0之后添加的屬性動畫框架 ·屬性動畫Animator & 傳統動畫Animation ·Sample { TranslateAnimation animation = new TranslateAnimation(0, 200, 0, 0); // x從0->200 animation.setDuration(1000); // 持續時間1s animation.setFillAfter(true); // 動畫運行完成后停留在原處 imageView.startAnimation(animation); // 開始動畫 } ·如果給控件點擊事件,動畫結束之后,事件的響應就會詭異了,啊啊啊,這是一個Bug呀,詭異詭異 -> { Animation動畫只是進行了重繪控件,但是響應位置卻沒有改變,不適合帶交互的動畫 Animator動畫則是onDraw不斷重繪,而且只支持四種動畫 } -> 這里的表述有點小問題查看全部
-
常用方法查看全部
舉報
0/150
提交
取消