Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

SharedElementTransition #65

Open
Aqua-Ye opened this issue Apr 25, 2018 · 1 comment
Open

SharedElementTransition #65

Aqua-Ye opened this issue Apr 25, 2018 · 1 comment

Comments

@Aqua-Ye
Copy link

Aqua-Ye commented Apr 25, 2018

I'm trying to make the Slidr work with SharedElementTransition.
I have an image on Activity A, that transitions to Activity B.
I then start to swipe back to Activity A, but the image is blank in Activity A while the slide occurs.
It only appears when the finish() method of the Activity B is called (by Slidr)

Any idea how I could make the image visible on Activity A as soon as the drag starts?

@hakonschia
Copy link

hakonschia commented Oct 12, 2021

Late answer, but maybe it will be useful for someone else.

As far as I can tell by looking at the code, the framework for shared element transitions simply sets the alpha of the views to 0 (search for the class ActivityTransitionCoordinator.java and the method hideViews()). Therefore all we have to do is set it back manually.

val options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, view, "transitionName")
startActivity(intent, options.toBundle())

MainScope().launch {
    delay(750)
    view.alpha = 1f
}

There needs to be some delay, presumably to be sure that the framework sets the alpha to 0 first. Ideally a listener would be used, but I'm not sure if there is one for listening in the calling activity.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants