ObjectAnimator 簡易物件動作設定
public void setViewAnimation(View v)
{
AnimatorSet ans = new AnimatorSet();
ObjectAnimator[] ann = new ObjectAnimator[2];
ann[0] = ObjectAnimator.ofFloat(v,"scaleX",0,1);
ann[1] = ObjectAnimator.ofFloat(v,"scaleY",0,1);
ans.playTogether(ann);
ans.setDuration(1000);
ans.start();
}
可動畫屬性介紹
alpha: 透明度
scaleX: X 軸縮放
scaleY: Y 軸縮放
rotation: Z 軸旋轉
rotationX: X 軸旋轉
rotationY: Y 軸旋轉
translationX: X 軸移動
translationY: Y 軸移動
小 -> 放大 -> 縮小
ann[0] = ObjectAnimator.ofFloat(v,"scaleX",0,1.5,1);
ann[1] = ObjectAnimator.ofFloat(v,"scaleY",0,1.5,1);
這個動作可以從最小變到1.5倍之後再變回原始大小.