13

現在、私は Google Inbox の動作のような実装を試みてRecyclerViewおり、メールを開くアニメーションに非常に興味があります。

私の質問は次のとおりです。つまり、彼らはどの方法を使用したのですか?ItemAnimator.dispatchChangeStarting()親を埋めるために高さを使用して変更しましたか?それとも別の何か?もしそうなら、下にあるRecyclerView要素がわずかに見える間、プルジェスチャーでそれを閉じる方法。

ライブラリ、またはコードスニペット/例を指摘するのを手伝ってくれる人はいますか?

4

1 に答える 1

2

つまり、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;
}
于 2015-08-31T07:53:53.593 に答える