3
起始值使用ObjectAnimator
S,任選PropertyValuesHolder
S,也可以指定開始和動畫屬性結束值:指定ViewPropertyAnimator
ObjectAnimator animX = ObjectAnimator.ofFloat(myView, "x", 20f, 50f);
ObjectAnimator animY = ObjectAnimator.ofFloat(myView, "y", 30f, 100f);
AnimatorSet animSetXY = new AnimatorSet();
animSetXY.playTogether(animX, animY);
animSetXY.start();
PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat("x", 20f, 50f);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat("y", 30f, 100f);
ObjectAnimator.ofPropertyValuesHolder(myView, pvhX, pvyY).start();
我如何能實現相同的動畫與ViewPropertyAnimator
S'語法似乎並不支持初始值,假設他們等於值的觀點已經在動畫開始:
myView.animate().x(50f).y(100f); //Where do I put starting values??
感謝;)
只需setX和setY。 – Moritz
更糟糕的是,在您調用第一個ViewPropertyAnimator方法之前,視圖需要位於它們的開始位置(值)。 – 2015-08-06 15:05:51
更具體地說,「myView.animate()。x(50f)」準備動畫師從getX()(立即獲得)動畫到50f,然後再調用start。 – 2015-08-06 15:05:56