Android创建ViewPropertyAnimator动画链

Igo*_*gor 7 animation android view

我正在尝试这个:

public void onClick(View view){
    tv.animate().x(600).y(100).scaleX(3).scaleY(3);
    tv.animate().x(400).y(1400).scaleX(1).scaleY(1);
}
Run Code Online (Sandbox Code Playgroud)

但它会跳过第一行动画.如何让它链接起来,首先它会做第一行,然后是下一行?

Des*_*ert 17

你可以试试这个

 Runnable endAction = new Runnable() {
     public void run() {
         tv.animate().x(400).y(1400).scaleX(1).scaleY(1);
     }
 };

tv.animate().x(600).y(100).scaleX(3).scaleY(3).withEndAction(endAction);
Run Code Online (Sandbox Code Playgroud)

如文档中所建议的那样

  • 使用withEndAction你也可以使用ViewCompat:`ViewCompat.animate(tv).withEndAction(endAction)` (7认同)