hjr-Android:動畫效果

ObjectAnimator transXAnim = ObjectAnimator.ofFloat(myView, "translationX", -100, 300);//此處可以寫n個參數,執行時myView從0開始,負的向左正的向右,平移該數字的像素,此效果爲先向左100像素,再回到0,再向右300像素。 
ObjectAnimator transYAnim = ObjectAnimator.ofFloat(myView, "tranlsationY", 0, 100);//此處可以寫n個參數,執行時myView從0開始,負的向下正的向上,平移該數字的像素,此效果爲向上300像素。 
ObjectAnimator alphaAnim = ObjectAnimator.ofFloat(myView, "alpha", 1.0f, 0.5f, 0.8f, 1.0f);//此處可以寫n個參數,執行時myView不透明度從100%到50%到80%到100%, 
ObjectAnimator scaleXAnim = ObjectAnimator.ofFloat(myView, "scaleX", 0.0f, 1.0f);//此處可以寫n個參數,執行時myView根據x軸縮放從0%到100%。 
ObjectAnimator scaleYAnim = ObjectAnimator.ofFloat(myView, "scaleY", 0.0f, 2.0f);//此處可以寫n個參數,執行時myView根據y軸縮放從0%到200%。 
ObjectAnimator rotateAnim = ObjectAnimator.ofFloat(myView, "rotation", 0, 360);//此處可以寫n個參數,執行時myView從0度旋轉到360度
AnimatorSet set = new AnimatorSet();                           set.playTogether(transXAnim,transXAnim);//此處可以多個動畫效果同步執行
set.setDuration(2000);//設置執行完總時間
set.start();
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章