问题
I would like to know whether it is possible to change the z-order of a shared element transition? Look:
I have a layout with an image, that fills the whole screen. In front of the image is a textbox which shows the title of the image. If I klick on the textbox, the transition to the detail activity starts. Therefore I implemented a shared element transition, in which the fullscreen image animates to a smaller version of itself in the detail view. The picture below illustrates this behaviour.
My problem now is that in both activities are textboxes, that are placed above the shared element image. And if I went from overview to detail activity, I see the circle textbox with the number only after the shared element transition is finished. I would like to place the textbox with the number above the shared element transition, so that I could do an animation on this view element, too.
any idea on how to solve this?
回答1:
If I'm not mistaken, android calculates which views are on top of others by using the elevation of the views. Try playing around with the elevations (or the translationZ values) to decide which view(s) should be on top.
回答2:
Solution : ViewGroupTree
Solution
level 0 : MainConstraint //(your row)
level 1 : ImageView / Otherlayout
level 2 : TextView
item A::BackgroundImage : MainConstraint -> ImageView
item B::BackgroundTextView : MainConstraint -> Constraint -> TextView
With this, the layout are Z index order are messed up. because ImageView and TextView have different layout hierarchy, add your ImageView inside an other layout and it's will work as expected !! You have to use the same level of deep for each of your view to get a, expected call
I hope it's not late ;)
来源:https://stackoverflow.com/questions/32348018/shared-element-transition-foreground-background-issue