我有一个显示图像的Viewpager。如果我单击其中一张图像,则希望在该单击上显示一些动画。 所以现在我有了一个AnimatorSet,其中包含多个ObjectAnimator对象。
private void onImageclick()
{
mSetRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(context,R.animator.out_animation);
mSetLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(context,R.animator.in_animation);
mSetRightOut.setTarget(mCardFrontLayout);
mSetLeftIn.setTarget(mCardBackLayout);
mSetRightOut.start();
mSetLeftIn.start();
}
关注以下博文https://www.thedroidsonroids.com/blog/how-to-add-card-flip-animation-to-your-android-app
动画不会在viewpager中工作,但是如果我复制此代码并将其放入任何正常活动或片段中,它将起作用。 普通的单个ObjectAnimator也可以在ViewPager中使用,但是如果我将它们捆绑在AnimatorSet中,它将无法进行动画处理。