Description: I am facing an issue in Lollipop and marshmallow devices when implementing MaterialContainerTransform Transition in Activity to Activity transition. I have a recycle view in grid mode with 4 column whenever i click on item it transforms exactly same as it should behave but it is behaving unexpected in Lollipop and marshmallow devices. The problem is when transition ends on going back to previous activity, the current item box comes from last item position. I don't know why it is happening in only lollipop and marshmallow only.
Expected behavior: Transition Issue on going back to previous activity, On transition ending, the current item box animate from wrong item position in the end in lollipop and marshmallow devices.
Source code: Activity A:-
override fun onCreate(savedInstanceState: Bundle?) {
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
setExitSharedElementCallback(MaterialContainerTransformSharedElementCallback())
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_facility_listing)
}
Activity B:-
override fun onCreate(savedInstanceState: Bundle?) {
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
setEnterSharedElementCallback(MaterialContainerTransformSharedElementCallback())
setExitSharedElementCallback(MaterialContainerTransformSharedElementCallback())
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_facility_listing)
val transition = intent.getStringExtra("transition")
findViewById
window.sharedElementEnterTransition = MaterialContainerTransform().apply {
addTarget(R.id.containerlayout)
scrimColor = Color.TRANSPARENT
duration = 400L
}
window.sharedElementReturnTransition = MaterialContainerTransform().apply {
addTarget(R.id.containerlayout)
scrimColor = Color.TRANSPARENT
duration = 300L
}
}
On item click:-
var adapter = HomeCategoryAdapter(list, activity);
categoryRecycleView.adapter = adapter;
adapter.setOnCategoryListener(object : HomeCategoryAdapter.OnClickCategoryListener {
override fun onClickCategory(
view: View,
position: Int,
categoryHomeModel: CategoryHomeModel
) {
//var pair1 = Pair<View,String>(searchbtn,"search_bar")
var pair2 = Pair<View, String>(view, view.transitionName)
val options = ActivityOptions.makeSceneTransitionAnimation(activity, pair2)
var intent = Intent(activity, FacilityListingActivity::class.java)
intent.putExtra("transition", view.transitionName)
intent.putExtra("position", position)
intent.putExtra("categoryname", categoryHomeModel.text)
startActivity(intent, options.toBundle())
}
})
Material Library version: com.google.android.material:material:1.2.0-beta01
Device: In lollipop and Marshmallow device only.
To help us triage faster, please check to make sure you are using the latest version of the library.
We also happily accept pull requests.
Spelling 3 out of 4 Android versions wrong in the same title is probably a record
Thanks for correcting me...
I think there is also a bug in the container transform animation between 2 views. The bug appeared in the last update of the library. The first animation works as expected (although not optimal), but if you try to revert the animation the app freezes for several seconds.
Most helpful comment
Thanks for correcting me...