谷歌的收件箱就像RecyclerView项目开放的动画 [英] Google Inbox like RecyclerView item open animation

查看:196
本文介绍了谷歌的收件箱就像RecyclerView项目开放的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在试图实现谷歌的收件箱就像 RecyclerView behaivior,我很好奇电子邮件开场动画。

Currently, I'm trying to implement Google Inbox like RecyclerView behaivior, and I'm very curious about email opening animation.

我的问题是:如何做到这一点?我的意思是,他们使用哪种方法?难道他们使用 ItemAnimator.dispatchChangeStarting()并改变它的高度,以填补父?还是另一种东西?如果他们这样做,他们是如何使其接近上拉动作,而底层 RecyclerView 元素稍微明显。

My question is: how to do that? I mean, which method they used? Did they use ItemAnimator.dispatchChangeStarting() and change it's height to fill parent? Or something another? And if they do, how they make it close with pull gesture while underlying RecyclerView elements are slightly visible.

谁能帮我指着一些图书馆,或code片段/例子吗?

Can anyone help me with pointing to some library, or code snippets/examples?

推荐答案

您的意思是:在recyclerview作为负载的项目,或者一旦一个项目,pressing加载下一个屏幕。

You mean: the recyclerview as a load items, or once an item and pressing load the next screen.

我离开了我是如何收取的recyclerview项目一个例子,我举一个动画

I leave an example of how I charge items in recyclerview and I give an animation

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:

In your RecyclerViewAdapter:

@Override
public void onBindViewHolder(ViewHolder viewHolder, int position) {

    GruposCardView gruposCardView = gruposCardViews.get(position);

    CreateAnimationView.createAnimationRandom(viewHolder.cardView);
   ...}

如果不是在recyclerview你可以传递一个布局,并使用该动画或创建一个来源于此。

And if not in the recyclerview you can pass a layout and use this animation or create one from this.

 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;
}

这篇关于谷歌的收件箱就像RecyclerView项目开放的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆