Interface

SharedTransitionScope.SharedContentConfig

SharedContentConfig allows a shared element to be disabled or enabled dynamically through isEnabled property.

Source set: Common
public interface SharedContentConfig

SharedContentConfig allows a shared element to be disabled or enabled dynamically through isEnabled property. By default, shouldKeepEnabledForOngoingAnimation is true. This means if the shared element transition is already running for the layout that this SharedContentConfig is applied to, we will keep the shared element enabled until the animation is finished. In other words, disabling shared element while the animation is in-flight will have no effect, unless shouldKeepEnabledForOngoingAnimation is overridden.

alternativeTargetBoundsInTransitionScopeAfterRemoval defines an alternative target bounds for when the target shared element is disposed amid animation (e.g., scrolled out of the viewport and subsequently disposed). By default, no alternative target bounds is defined - As soon as the target shared element (i.e. the shared element in the incoming/target content) is removed, the shared element transition for the shared elements with the same key will be cancelled.

Properties

isEnabled

Source set: Common
public val SharedContentState.isEnabled: Boolean

isEnabled returns a boolean indicating whether the shared element is enabled. By default, it is true.

shouldKeepEnabledForOngoingAnimation

Source set: Common
public val shouldKeepEnabledForOngoingAnimation: Boolean

shouldKeepEnabledForOngoingAnimation returns a boolean indicating whether the shared element should be enabled for ongoing animation. By default, shared elements will be kept enabled for ongoing animation until the animation is finished. This means disabling shared element while the animation is in-flight will have no effect, unless shouldKeepEnabledForOngoingAnimation is overridden to return false. This default is intended to ensure a continuous experience out-of-the-box by avoiding accidentally removing in-flight animations.

permitTransformDuringDeferredTransition

Source set: Common
@Deprecated(
            message =
                "Override deferredTransitionBehavior instead: return " +
                    "DeferredTransitionBehavior.Static for false, or " +
                    "DeferredTransitionBehavior.FollowContainer for true."
        )
        public val permitTransformDuringDeferredTransition: Boolean

Deprecated: Override deferredTransitionBehavior instead:

override val deferredTransitionBehavior = DeferredTransitionBehavior.Static

permitTransformDuringDeferredTransition defines whether the shared element should take part in the manual transformations applied to its container during the deferred phase of a DeferredTransition. If true, the element visually transforms with its container until the transition switches to the automatic phase. This makes it look like it remains visually attached to its parent container. If false, it remains statically detached in its start position during the deferred phase.

deferredTransitionBehavior

Source set: Common
public val deferredTransitionBehavior: DeferredTransitionBehavior

Defines how the shared element behaves during the deferred phase of a DeferredTransition.

By default, this returns DeferredTransitionBehavior.FollowContainer, meaning the element visually transforms (scale, offset) with its parent container until the transition switches to the automatic phase.

Use DeferredTransitionBehavior.Static to detach the element from its container's manual transformations and keep it at its initial bounds, or DeferredTransitionBehavior.SeekToTarget to interpolate between its initial and target bounds when MutableContentTransform.sharedElementProgress is configured.

Functions

alternativeTargetBoundsInTransitionScopeAfterRemoval

Source set: Common
public fun SharedContentState.alternativeTargetBoundsInTransitionScopeAfterRemoval(
            targetBoundsBeforeRemoval: Rect,
            sharedTransitionLayoutSize: Size,
        ): Rect?

alternativeTargetBoundsInTransitionScopeAfterRemoval returns an alternative target bounds for when the target shared element is disposed amid animation (e.g., scrolled out of the viewport and subsequently disposed).

By default, no alternative target bounds is defined - As soon as the target shared element (i.e. the shared element in the incoming/target content) is removed, the shared element transition for the shared elements with the same key will be cancelled.

Parameters

targetBoundsBeforeRemoval The target bounds of the shared element relative to the SharedTransitionLayout before it is removed.
sharedTransitionLayoutSize The size of the shared transition layout for convenient calculation.
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: