Duncan Duncan - 1 year ago 212
Android Question

Shared Element Transition not working on first load with Picasso

I am trying to load an image from a URL into an

using Picasso.

The image for the shared transition is inside a
in a
and the second it just in a LinearLayout.
The first time the request is made the element doesn't animate as picasso needs to load the image into the view, but on subsequent requests it is fine.

How can I ensure that the
has been successfully populated before initiating the transition?

Answer Source

The solution was in using the postponeEnterTransition() and startPostponedEnterTransition() calls to ensure that picasso has finished loading the image into the view before the activity starts.

This is a great blog entry about this.

Below is an example of what you might use in onCreate

    .into(((ImageView) findViewById(R.id.game_view_image)), new Callback() {
        public void onSuccess() {

        public void onError() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download