Open devmichealmurray opened 3 years ago
I had the same problem in my own app first time I tried that, the problem was because I put the transitionName and the click listener in two different elements views in XML, you have to make sure to give a unique android:transitionName
to the view you send in the argument when clicking, for example:
The right way:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:layout_width="130dp"
android:layout_height="match_parent"
android:transitionName="@{@string/post_card_transition_name(post.id)}"
android:onClick="@{(view) -> clickListener.onClick(view, post)}"
...
and my string is: <string name="place_card_transition_name">post_card_%1$s</string>
if you see, in this case, android:transitionName
will return post_card_1, post_card_2 post_card_3 etc...
The wrong way:
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:onClick="@{(view) -> clickListener.onClick(view, post)}">
<androidx.cardview.widget.CardView
android:layout_width="130dp"
android:layout_height="match_parent"
android:transitionName="@{@string/post_card_transition_name(post.id)}"
...
In the second case, you are sending constraintLayout as a view that has no transitionName to it
So when the message says Unique transitionNames are required for all sharedElements
that probably means either, you have views with the same transition name, or the attribute is not set and that will result in android:transitionName
to be null
... in other words, all the others view elements!
See if your problem seems like that, the transition effect is so awesome, I will definitely always use that from now on
In Section 4 at this point in the CodeLab:
The app crashes with this IllegalArgumentException: