SharedElementCallback
abstract class SharedElementCallback
kotlin.Any | |
↳ | android.app.SharedElementCallback |
Listener provided in Activity.setEnterSharedElementCallback(SharedElementCallback)
and Activity.setExitSharedElementCallback(SharedElementCallback)
as well as Fragment.setEnterSharedElementCallback(SharedElementCallback)
and Fragment.setExitSharedElementCallback(SharedElementCallback)
to monitor the Shared element transitions. The events can be used to customize Activity and Fragment Transition behavior.
Summary
Nested classes | |
---|---|
abstract |
Listener to be called after |
Public constructors | |
---|---|
Public methods | |
---|---|
open Parcelable! |
onCaptureSharedElementSnapshot(: View!, : Matrix!, : RectF!) Creates a snapshot of a shared element to be used by the remote Activity and reconstituted with |
open View! |
onCreateSnapshotView(: Context!, : Parcelable!) Reconstitutes a snapshot View from a Parcelable returned in |
open Unit |
onMapSharedElements(: MutableList<String!>!, : MutableMap<String!, View!>!) Lets the SharedElementCallback adjust the mapping of shared element names to Views. |
open Unit |
Called after |
open Unit |
onSharedElementEnd(: MutableList<String!>!, : MutableList<View!>!, : MutableList<View!>!) In Activity Transitions, onSharedElementEnd is called immediately before capturing the end of the shared element state on enter and reenter transitions and immediately before capturing the start of the shared element state for exit and return transitions. |
open Unit |
onSharedElementStart(: MutableList<String!>!, : MutableList<View!>!, : MutableList<View!>!) In Activity Transitions, onSharedElementStart is called immediately before capturing the start of the shared element state on enter and reenter transitions and immediately before capturing the end of the shared element state for exit and return transitions. |
open Unit |
onSharedElementsArrived(: MutableList<String!>!, : MutableList<View!>!, : SharedElementCallback.OnSharedElementsReadyListener!) Called during an Activity Transition when the shared elements have arrived at the final location and are ready to be transferred. |
Public constructors
SharedElementCallback
SharedElementCallback()
Public methods
onCaptureSharedElementSnapshot
open fun onCaptureSharedElementSnapshot(
: View!,
: Matrix!,
: RectF!
): Parcelable!
Creates a snapshot of a shared element to be used by the remote Activity and reconstituted with onCreateSnapshotView(android.content.Context,android.os.Parcelable)
. A null return value will mean that the remote Activity will have a null snapshot View in onSharedElementStart(java.util.List,java.util.List,java.util.List)
and onSharedElementEnd(java.util.List,java.util.List,java.util.List)
.
This is not called for Fragment Transitions.
Parameters | |
---|---|
sharedElement |
View!: The shared element View to create a snapshot for. |
viewToGlobalMatrix |
Matrix!: A matrix containing a transform from the view to the screen coordinates. |
screenBounds |
RectF!: The bounds of shared element in screen coordinate space. This is the bounds of the view with the viewToGlobalMatrix applied. |
Return | |
---|---|
Parcelable! |
A snapshot to send to the remote Activity to be reconstituted with onCreateSnapshotView(android.content.Context,android.os.Parcelable) and passed into onSharedElementStart(java.util.List,java.util.List,java.util.List) and onSharedElementEnd(java.util.List,java.util.List,java.util.List) . |
onCreateSnapshotView
open fun onCreateSnapshotView(
: Context!,
: Parcelable!
): View!
Reconstitutes a snapshot View from a Parcelable returned in onCaptureSharedElementSnapshot(android.view.View,android.graphics.Matrix,android.graphics.RectF)
to be used in onSharedElementStart(java.util.List,java.util.List,java.util.List)
and onSharedElementEnd(java.util.List,java.util.List,java.util.List)
. The returned View will be sized and positioned after this call so that it is ready to be added to the decor View's overlay.
This is not called for Fragment Transitions.
Parameters | |
---|---|
context |
Context!: The Context used to create the snapshot View. |
snapshot |
Parcelable!: The Parcelable returned by onCaptureSharedElementSnapshot(android.view.View,android.graphics.Matrix,android.graphics.RectF) . |
Return | |
---|---|
View! |
A View to be sent in onSharedElementStart(java.util.List,java.util.List,java.util.List) and onSharedElementEnd(java.util.List,java.util.List,java.util.List) . A null value will produce a null snapshot value for those two methods. |
onMapSharedElements
open fun onMapSharedElements(
: MutableList<String!>!,
: MutableMap<String!, View!>!
): Unit
Lets the SharedElementCallback adjust the mapping of shared element names to Views.
Parameters | |
---|---|
names |
MutableList<String!>!: The names of all shared elements transferred from the calling Activity or Fragment in the order they were provided. |
sharedElements |
MutableMap<String!, View!>!: The mapping of shared element names to Views. The best guess will be filled into sharedElements based on the transitionNames. |
onRejectSharedElements
open fun onRejectSharedElements(: MutableList<View!>!): Unit
Called after onMapSharedElements(java.util.List,java.util.Map)
when transferring shared elements in. Any shared elements that have no mapping will be in rejectedSharedElements. The elements remaining in rejectedSharedElements will be transitioned out of the Scene. If a View is removed from rejectedSharedElements, it must be handled by the SharedElementCallback
.
Views in rejectedSharedElements will have their position and size set to the position of the calling shared element, relative to the Window decor View and contain snapshots of the View from the calling Activity or Fragment. This view may be safely added to the decor View's overlay to remain in position.
This method is not called for Fragment Transitions. All rejected shared elements will be handled by the exit transition.
Parameters | |
---|---|
rejectedSharedElements |
MutableList<View!>!: Views containing visual information of shared elements that are not part of the entering scene. These Views are positioned relative to the Window decor View. A View removed from this list will not be transitioned automatically. |
onSharedElementEnd
open fun onSharedElementEnd(
: MutableList<String!>!,
: MutableList<View!>!,
: MutableList<View!>!
): Unit
In Activity Transitions, onSharedElementEnd is called immediately before capturing the end of the shared element state on enter and reenter transitions and immediately before capturing the start of the shared element state for exit and return transitions.
In Fragment Transitions, onSharedElementEnd is called immediately before capturing the end state of all shared element transitions.
This call can be used to adjust the transition end state by modifying the shared element Views. Note that no layout step will be executed between onSharedElementEnd and the transition state capture.
Any changes made in onSharedElementStart(java.util.List,java.util.List,java.util.List)
that are not updated during layout should be corrected in onSharedElementEnd. For example, rotation or scale will not be affected by layout and if changed in onSharedElementStart(java.util.List,java.util.List,java.util.List)
, it will also have to be reset in onSharedElementEnd again to correct the end state.
Parameters | |
---|---|
sharedElementNames |
MutableList<String!>!: The names of the shared elements that were accepted into the View hierarchy. |
sharedElements |
MutableList<View!>!: The shared elements that are part of the View hierarchy. |
sharedElementSnapshots |
MutableList<View!>!: The Views containing snap shots of the shared element from the launching Window. These elements will not be part of the scene, but will be positioned relative to the Window decor View. This list will be null for Fragment Transitions. |
onSharedElementStart
open fun onSharedElementStart(
: MutableList<String!>!,
: MutableList<View!>!,
: MutableList<View!>!
): Unit
In Activity Transitions, onSharedElementStart is called immediately before capturing the start of the shared element state on enter and reenter transitions and immediately before capturing the end of the shared element state for exit and return transitions.
In Fragment Transitions, onSharedElementStart is called immediately before capturing the start state of all shared element transitions.
This call can be used to adjust the transition start state by modifying the shared element Views. Note that no layout step will be executed between onSharedElementStart and the transition state capture.
For Activity Transitions, any changes made in onSharedElementEnd(java.util.List,java.util.List,java.util.List)
that are not updated during by layout should be corrected in onSharedElementStart for exit and return transitions. For example, rotation or scale will not be affected by layout and if changed in onSharedElementEnd(java.util.List,java.util.List,java.util.List)
, it will also have to be reset in onSharedElementStart again to correct the end state.
Parameters | |
---|---|
sharedElementNames |
MutableList<String!>!: The names of the shared elements that were accepted into the View hierarchy. |
sharedElements |
MutableList<View!>!: The shared elements that are part of the View hierarchy. |
sharedElementSnapshots |
MutableList<View!>!: The Views containing snap shots of the shared element from the launching Window. These elements will not be part of the scene, but will be positioned relative to the Window decor View. This list is null for Fragment Transitions. |
onSharedElementsArrived
open fun onSharedElementsArrived(
: MutableList<String!>!,
: MutableList<View!>!,
: SharedElementCallback.OnSharedElementsReadyListener!
): Unit
Called during an Activity Transition when the shared elements have arrived at the final location and are ready to be transferred. This method is called for both the source and destination Activities.
When the shared elements are ready to be transferred, OnSharedElementsReadyListener.onSharedElementsReady()
must be called to trigger the transfer.
The default behavior is to trigger the transfer immediately.
Parameters | |
---|---|
sharedElementNames |
MutableList<String!>!: The names of the shared elements that are being transferred.. |
sharedElements |
MutableList<View!>!: The shared elements that are part of the View hierarchy. |
listener |
SharedElementCallback.OnSharedElementsReadyListener!: The listener to call when the shared elements are ready to be hidden in the source Activity or shown in the destination Activity. |