谷歌收件箱类似RecyclerView项目打开动画



目前,我正在尝试实现类似RecyclerView behaivior的谷歌收件箱,我对电子邮件打开动画非常好奇。

我的问题是:如何做到这一点?我的意思是,他们用了哪种方法?他们是否使用ItemAnimator.dispatchChangeStarting()并更改其高度以填充父对象?或者其他什么?如果他们这样做了,他们是如何在底层RecyclerView元素稍微可见的情况下,用拉手势将其闭合的。

有人能帮我指出一些库或代码片段/示例吗?

您的意思是:recyclerview作为一个加载项目,或者一次加载一个项目并按下加载下一个屏幕。

我留下了一个如何在回收站收费的例子,并给出了一个动画

public class CreateAnimationView {
private static int contador;
Integer colorFrom = R.color.myAccentColor;
Integer colorTo = Color.RED;
public static AnimatorSet createAnimation(View view) {
    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(view, "alpha",
            0f);
    fadeOut.setDuration(300);
    ObjectAnimator mover = ObjectAnimator.ofFloat(view,
            "translationX", -500f, 0f);
    mover.setDuration(400);
    ObjectAnimator fadeIn = ObjectAnimator.ofFloat(view, "alpha",
            0f, 1f);
    fadeIn.setDuration(300);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.play(mover);
    animatorSet.start();
    return animatorSet;
 }
... more animations methods.
}

在您的RecyclerViewAdapter:中

@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {
    GruposCardView gruposCardView = gruposCardViews.get(position);
    CreateAnimationView.createAnimationRandom(viewHolder.cardView);
   ...}

如果不在回收视图中,您可以传递布局并使用此动画或根据此创建动画。

 public static AnimatorSet createAnimationCollapseXY(View view) {
    ObjectAnimator scaleXOut = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0f).setDuration(400);
    ObjectAnimator scaleXIn = ObjectAnimator.ofFloat(view, "scaleX", 0f, 1f).setDuration(300);
    ObjectAnimator scaleYOut = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0f).setDuration(400);
    ObjectAnimator scaleYIn = ObjectAnimator.ofFloat(view, "scaleY", 0f, 1f).setDuration(300);
    ObjectAnimator rotateClockWise = ObjectAnimator.ofFloat(view, "rotation", 0f, 360f).setDuration(400);
    ObjectAnimator rotateCounterClockWise = ObjectAnimator.ofFloat(view, "rotation", 0f, -360f).setDuration(400);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(scaleXIn, scaleYIn);
    //animatorSet.setStartDelay(1200);
    animatorSet.start();
    return animatorSet;
}

相关内容

  • 没有找到相关文章

最新更新