CollapsingToolbarLayout title as a shared element transition
S

2

32

I have a TextView in my activity A. How can I make shared element transition of TextView from activity A and a title of CollapsingToolbarLayout.setTitle() from activity B?

Is there way to obtain its title view id from CollapsingToolbarLayout's source code?

Thanks for help!

Shabbygenteel answered 13/9, 2015 at 9:18 Comment(3)
In theory you could nest a dummy TextView with exactly the same position, color and size inside your CollapsingToolbarLayout. Then just after the transition end you hide it and that will make the illusion. But I had problems with the correct positioning inside CollapsingToolbarLayout relative to the bottom. It was always was somewhat incorrect.Tillietillinger
@Tillietillinger Yes, I almost achieve this effect with same way. But better solution is not to use embedded title in collapsing layout but create own TextView title with coordinator behavior like here: github.com/saulmm/CoordinatorBehaviorExample and easily use it with shared element transitions.Shabbygenteel
10x for the good advice and the example!Tillietillinger
C
3

I've had similar issue. My app had CollapsingToolbar which had image in it and I wanted to share the image which was going from normal ListView into the CollapsingToolbar.

You need to create a custom TextView and use it as a replacement of the actual title in CollapsingToolbar. Also need to set the actual title to empty string so it looks hidden.

You should look into this answer where its shown how to use custom view in CollapsingToolbar with the listener which is needed to replicate animations of normal title. It may not look identical but I can't think of better idea. Hope it was helpful.

Centiliter answered 11/5, 2016 at 17:10 Comment(0)
A
2

You can just use the collapsing tool bar as the target of the animation and it looks ok, but also animates the back button or drawer indicator which may not be what you want.

Asuncionasunder answered 1/3, 2016 at 23:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.