In my app, I have a splash logo screen at startup. I apply shared transition to that splash logo image when home screen is launched at timer's end. During the transition, it moves from centre ( of splash screen) to top-left corner (of home screen's toolbar).
I'm using AppbarLayout and Toolbar. I'm using two different variants of app bar to achieve following design. After creating two (land/appbar_home and layout/appbar_home) layouts, included them in fragment_home ( which has coordinator layout as top).
The entire code was working well until I started using android libraries ( appcompat, support & design) of version 23.0.0. After moving to the higher version (23.0.0) of libraries, transition stopped for portrait mode. but same time it was working well if device held in landscape mode.
After failing in few local fixes, decided to try the scenario in the different project. In the new project, I added one app bar layout (layout/appbar_home) animation was working great but as soon as I added land/appbar_home, it stopped in portrait mode. In landscape mode, it animates as expected. You can see the testing project on github.
It seems like some problem with the library. But if not, what's wrong with the code or approach.
This does seem like a problem with the library, but I have a way you can make it work for now until it is fixed.
If you set the transitionName in code instead of the XML, it will work for portrait and landscape:
update both your portrait and landscape appbar_home.xml layouts to give the ImageView an id:
<ImageView
android:id="@+id/appbar_logo"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_margin="5dp"
android:adjustViewBounds="true"
android:src="@drawable/rnd_1"
android:transitionName="@string/transition_logo" />
And then in your HomeActivityFragment, set the transitionName in your onCreateView:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
ImageView appBarLogo = (ImageView) rootView.findViewById(R.id.appbar_logo);
ViewCompat.setTransitionName(appBarLogo, "logo_transition");
return rootView;
}