Shared element transition in RecyclerView

后端 未结 1 983
囚心锁ツ
囚心锁ツ 2021-02-02 16:05

I am trying to use shared element transition on RecyclerView but it doesn\'t seem to work.

This is a part of my adapter in which I use makeSceneTransitionAnimation

1条回答
  •  再見小時候
    2021-02-02 17:01

    In your Adapter

    holder.smallThumbnail.setTransitionName("thumbnailTransition");
    Pair pair1 = Pair.create((View) holder.smallThumbnail, holder.smallThumbnail.getTransitionName());
    
    ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation((Activity) mContext, pair1, pair2);
    mContext.startActivity(intent, optionsCompat.toBundle());
    

    In Your Detail Activity

    getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element_transation));
    mainImage.setTransitionName("thumbnailTransition");
    

    Here this mainimage is imageview where you want to transform your previous activity thumbnail

    shared_element_transation create one xml in res>transition

    
    
    
    
    
    

    0 讨论(0)
提交回复
热议问题