Google Inbox like RecyclerView item open animation

前端 未结 1 2069
庸人自扰
庸人自扰 2021-01-31 00:41

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

My question is: how to do

相关标签:
1条回答
  • 2021-01-31 01:01

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

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

    In your RecyclerViewAdapter:

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

    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;
    }
    
    0 讨论(0)
提交回复
热议问题