2015-02-20 13 views
13

Derzeit versuche ich Google Mail Posteingang wie RecyclerView behavior, und ich bin sehr neugierig auf E-Mail-Eröffnung Animation.Google Posteingang wie RecyclerView Element öffnen Animation

Meine Frage ist: wie geht das? Ich meine, welche Methode haben sie benutzt? Haben sie ItemAnimator.dispatchChangeStarting() benutzt und ihre Höhe geändert, um Eltern zu füllen? Oder etwas anderes? Und wenn sie es tun, wie sie es mit Pull-Geste schließen, während darunter liegende Elemente leicht sichtbar sind.

Kann mir jemand helfen, wenn ich auf eine Bibliothek oder Codeschnipsel/Beispiele zeige?

Antwort

2

Sie meinen: die Recyclerview als Lade Artikel, oder einmal einen Artikel und drücken Sie den nächsten Bildschirm laden.

Ich lasse ein Beispiel, wie ich Elemente in recyclerview aufzuladen und ich gebe eine 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 Ihrem RecyclerViewAdapter:

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

    GruposCardView gruposCardView = gruposCardViews.get(position); 

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

Und im recyclerview wenn nicht, können Sie ein Layout übergeben und nutze diese Animation oder erstelle eine davon.

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