I have the following situation inside of a soccer application.
We want to implement the shared elements between all these activities.
In my viewholder on the first Activity
for the match I have set a android:transitionName
which corresponds to the same transitionName on the second Activity
.
<!-- item_viewholder (first activity) -->
<CustomViewContainingImageViewAndTextView
android:id="@+id/item_match_hometeam"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:transitionName="@string/transition_morph_match_header_homeTeam" />
<!-- header (second activity) -->
<CustomViewContainingImageViewAndTextView
android:id="@+id/item_match_hometeam_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:transitionName="@string/transition_morph_match_header_homeTeam" />
I start the second Activity
with
final String awayTeamTransition = activityContext.getString(R.string.transition_morph_match_header_awayTeam);
final String homeTeamTransition = activityContext.getString(R.string.transition_morph_match_header_homeTeam);
final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
activityContext,
Pair.create(homeTeam, homeTeamTransition),
Pair.create(awayTeam, awayTeamTransition));
activityContext.startActivity(intent, options.toBundle());
Now this transition works fine but what if I want to have an even deeper detail.
Displaying statistics about the selected team and I want to have shared transition there too?
I tried setting the transitionName
programmatically when the CustomViewContainingImageViewAndTextView
was clicked to the new transitionName
.
final String teamViewTransition = activityContext.getString(R.string.transition_morph_teamview_to_detail);
//teamView is the view that was clicked.
ViewCompat.setTransitionName(teamView, teamViewTransition);
final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(
activityContext,
Pair.create(teamView, teamViewTransition));
activityContext.startActivity(teamInfoActivityIntent, options.toBundle());
this transitionName corresponds to the ImageView
on the third Activity
<ImageView
android:id="@+id/team_info_header_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:transitionName="@string/transition_morph_teamview_to_detail" />
However the enterTransition fails, but the exitTransition works!
However this breaks the exitTransition from 2 --> 1
Sight. Hope someone takes some time to figure this out.
Thanks in advance