Android APIs
public abstract class

SharedElementListener

extends Object
java.lang.Object
   ↳ android.app.SharedElementListener

Class Overview

Listener provided in setEnterSharedElementListener(SharedElementListener) and setExitSharedElementListener(SharedElementListener) to monitor the Activity transitions. The events can be used to customize Activity Transition behavior.

Summary

Public Constructors
SharedElementListener()
Public Methods
void handleRejectedSharedElements(List<View> rejectedSharedElements)
Called after remapSharedElements(java.util.List, java.util.Map) when transferring shared elements in.
void remapSharedElements(List<String> names, Map<StringView> sharedElements)
Lets the ActivityTransitionListener adjust the mapping of shared element names to Views.
void setSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots)
Called to allow the listener to customize the end state of the shared element when transferring in shared element state.
void setSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots)
Called to allow the listener to customize the start state of the shared element when transferring in shared element state.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public SharedElementListener ()

Public Methods

public void handleRejectedSharedElements (List<View> rejectedSharedElements)

Called after remapSharedElements(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 SharedElementListener.

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.

Parameters
rejectedSharedElements 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.

public void remapSharedElements (List<String> names, Map<StringView> sharedElements)

Lets the ActivityTransitionListener adjust the mapping of shared element names to Views.

Parameters
names The names of all shared elements transferred from the calling Activity to the started Activity.
sharedElements The mapping of shared element names to Views. The best guess will be filled into sharedElements based on the View names.

public void setSharedElementEnd (List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots)

Called to allow the listener to customize the end state of the shared element when transferring in shared element state.

Any customization done in setSharedElementStart(java.util.List, java.util.List, java.util.List) may need to be modified to the final state of the shared element if it is not automatically corrected by layout. For example, rotation or scale will not be affected by layout and if changed in setSharedElementStart(java.util.List, java.util.List, java.util.List), it will also have to be set here again to correct the end state.

Parameters
sharedElementNames The names of the shared elements that were accepted into the View hierarchy.
sharedElements The shared elements that are part of the View hierarchy.
sharedElementSnapshots 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.

public void setSharedElementStart (List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots)

Called to allow the listener to customize the start state of the shared element when transferring in shared element state.

The shared element will start at the size and position of the shared element in the launching Activity or Fragment. It will also transfer ImageView scaleType and imageMatrix if the shared elements in the calling and called Activities are ImageViews. Some applications may want to make additional changes, such as changing the clip bounds, scaling, or rotation if the shared element end state does not map well to the start state.

Parameters
sharedElementNames The names of the shared elements that were accepted into the View hierarchy.
sharedElements The shared elements that are part of the View hierarchy.
sharedElementSnapshots 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.