Linux 拨号vps windows公众号手机端

Android中如何同时播放多个动画

lewis 9年前 (2016-09-06) 阅读数 14 #程序编程
文章标签 android

在Android中可以使用AnimatorSet来同时播放多个动画。

首先,创建需要同时播放的动画对象,例如ObjectAnimator、ValueAnimator等。

然后,创建AnimatorSet对象,并使用playTogether()方法将需要同时播放的动画添加到AnimatorSet中。

最后,调用AnimatorSet的start()方法开始播放动画。

示例代码如下:

ObjectAnimator scaleXAnim = ObjectAnimator.ofFloat(view, "scaleX", 0.5f, 1.0f);
ObjectAnimator scaleYAnim = ObjectAnimator.ofFloat(view, "scaleY", 0.5f, 1.0f);

AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(scaleXAnim, scaleYAnim);
animatorSet.start();
版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门