gpt4 book ai didi

java - Google Inbox like RecyclerView 项目打开动画

转载 作者:搜寻专家 更新时间:2023-10-30 20:54:02 35 4
gpt4 key购买 nike

目前,我正在尝试实现类似 RecyclerView 行为的 Google Inbox,而且我对电子邮件打开动画非常好奇。

我的问题是:该怎么做?我的意思是,他们使用了哪种方法?他们是否使用了 ItemAnimator.dispatchChangeStarting() 并更改了它的高度以填充父级?或者别的东西?如果他们这样做了,他们如何在底层 RecyclerView 元素稍微可见的情况下通过拉手势关闭它。

谁能帮我指出一些库或代码 fragment/示例?

最佳答案

您的意思是: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);
...}

如果不在 recyclerview 中,您可以传递一个布局并使用此动画或从中创建一个。

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

关于java - Google Inbox like RecyclerView 项目打开动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28625505/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com