2017-10-21 2 views
0

私は小さなプロジェクト、イメージボード用のアプリケーションに取り組んでいます。私は100%マテリアルデザインを実装しようとしています。アニメーションをビュー遷移にフックする

https://www.youtube.com/watch?v=Tr6U3hclx8I

私は、各項目が持っているオーバーレイ用の小さなフェージングアニメーションを追加したいです。いくつかの項目をタップするとわかるように、上と下のオーバーレイの両方がフェードアウトのアニメーションを実行しています。物事は、それが戻ってきたときにアニメーションがちょっとぎこちないように見えます。ディテールからのイメージが縮小して元の位置に戻ってきてから、上下のオーバーレイにアニメーションがフェードインして戻ってくるようにしたいと思います。

ここで問題となるのは、これを行うための適切なフックが見つからないということです。つまり、どのようにトランジションアニメーションが終了したのかを知り、その後アニメーションをフェードインすることができますか?

ここでは、コードの少しです:

public void onItemClicked(final Vox vox, final VoxItemView view) { 
    //I'm using an AnimatorInflator to inflates these animations in the fragment's onCreate method 
    mFadeOutBottom.setTarget(view.getBottomOverlayView()); 
    mFadeOutTop.setTarget(view.getTopOverlayView()); 

    mFadeInBottom.setTarget(view.getBottomOverlayView()); 
    mFadeInTop.setTarget(view.getTopOverlayView()); 

    AnimatorSet animatorSet = new AnimatorSet(); 
    animatorSet.playTogether(mFadeOutBottom, mFadeOutTop); 


    animatorSet.addListener(new AnimatorListenerAdapter() { 
     @Override 
     public void onAnimationEnd(Animator animation) { 
      //When the animation ends then I jump to the detail screen 
      ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(
        getActivity(), 
        view.getImageView(), 
        ViewCompat.getTransitionName(view.getImageView())); 

      startActivity(VoxDetailActivity.getStartIntent(getActivity(), vox), options.toBundle()); 

      //I tried setting the fade in animation here, but it doesnt work 
      AnimatorSet animatorSet = new AnimatorSet(); 
      animatorSet.playTogether(mFadeInBottom, mFadeInTop); 
      animatorSet.start(); 
     } 
    }); 

    animatorSet.start(); 
} 

VoxItemViewsはRecyclerViewグリッドの図です。

誰かが正しい方向に私を指すことができるなら、私はそれを感謝します。

答えて

0

ここに自分自身の質問に答えると、誰かのために何か価値があるこの本当に有用な希望が見つかりました。

明らかに、共有遷移間を行き来するときに使用できるコールバックフックがあります。

このプロジェクトはそれを使用する方法についてのクールな例をいくつか持っている:

https://github.com/alexjlockwood/adp-activity-transitions/blob/master/app/src/main/java/com/alexjlockwood/activity/transitions/DetailsFragment.java

私はまだそれを自分で実装していませんでしたが、私はそれが進むべき道だと確信しています。

関連する問題