Android Guides | Samples

Android.Transitions.Transition Class

A Transition holds information about animations that will be run on its targets during a scene change.

See Also: Transition

Syntax

[Android.Runtime.Register("android/transition/Transition", DoNotGenerateAcw=true)]
public abstract class Transition : Object, ICloneable, IDisposable

Remarks

A Transition holds information about animations that will be run on its targets during a scene change. Subclasses of this abstract class may choreograph several child transitions (TransitionSet or they may perform custom animations themselves. Any Transition has two main jobs: (1) capture property values, and (2) play animations based on changes to captured property values. A custom transition knows what property values on View objects are of interest to it, and also knows how to animate changes to those values. For example, the Fade transition tracks changes to visibility-related properties and is able to construct and run animations that fade items in or out based on changes to those properties.

Note: Transitions may not work correctly with either SurfaceView or TextureView, due to the way that these views are displayed on the screen. For SurfaceView, the problem is that the view is updated from a non-UI thread, so changes to the view due to transitions (such as moving and resizing the view) may be out of sync with the display inside those bounds. TextureView is more compatible with transitions in general, but some specific transitions (such as Fade) may not be compatible with TextureView because they rely on ViewOverlay functionality, which does not currently work with TextureView.

Transitions can be declared in XML resource files inside the res/transition directory. Transition resources consist of a tag name for one of the Transition subclasses along with attributes to define some of the attributes of that transition. For example, here is a minimal resource file that declares a ChangeBounds transition:

xml Example

<changeBounds/>

xml Example

<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
    <explode/>
    <changeBounds/>
    <changeTransform/>
    <changeClipBounds/>
    <changeImageTransform/>
</transitionSet>

xml Example

<transition class="my.app.transition.CustomTransition"/>

xml Example

<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
     android:transitionOrdering="sequential">
    <changeBounds/>
    <fade android:fadingMode="fade_out" >
        <targets>
            <target android:targetId="@id/grayscaleContainer" />
        </targets>
    </fade>
</transitionSet>
Further information on XML resource descriptions for transitions can be found for NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#Transition, NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#TransitionSet, NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#TransitionTarget, NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#Fade, NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#Slide, and NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#ChangeTransform.

This TransitionSet contains Explode for visibility, ChangeBounds, ChangeTransform, and ChangeClipBounds and ChangeImageTransform:

Custom transition classes may be instantiated with a transition tag:

Custom transition classes loaded from XML should have a public constructor taking a Context and IAttributeSet.

Note that attributes for the transition are not required, just as they are optional when declared in code; Transitions created from XML resources will use the same defaults as their code-created equivalents. Here is a slightly more elaborate example which declares a TransitionSet transition with ChangeBounds and Fade child transitions:

In this example, the transitionOrdering attribute is used on the TransitionSet object to change from the default TransitionSet.OrderingTogether behavior to be TransitionSet.OrderingSequential instead. Also, the Fade transition uses a fadingMode of Fade.Out instead of the default out-in behavior. Finally, note the use of the targets sub-tag, which takes a set of NoType:android/R$styleable;Href=../../../reference/android/R.styleable.html#TransitionTarget tags, each of which lists a specific targetId, targetClass, targetName, excludeId, excludeClass, or excludeName, which this transition acts upon. Use of targets is optional, but can be used to either limit the time spent checking attributes on unchanging views, or limiting the types of animations run on specific views. In this case, we know that only the grayscaleContainer will be disappearing, so we choose to limit the Fade transition to only that view.

[Android Documentation]

Requirements

Namespace: Android.Transitions
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0

The members of Android.Transitions.Transition are listed below.

See Also: Object

Public Constructors

Constructs a Transition object with no target objects.
Perform inflation from XML and apply a class-specific base style from a theme attribute or style resource.

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

const
MatchIdMatchTarget (3). With Transition.setMatchOrder(int...), chooses to match by View.Id.
const
MatchInstanceMatchTarget (1). With Transition.setMatchOrder(int...), chooses to match by View instance.
const
MatchItemIdMatchTarget (4). With Transition.setMatchOrder(int...), chooses to match by the Adapter item id.
const
MatchNameMatchTarget (2). With Transition.setMatchOrder(int...), chooses to match by View.TransitionName.

Public Properties

[read-only]
DurationInt64. Returns the duration set on this transition.
[read-only]
EpicenterRect. Returns the epicenter as specified by the NoType:android/transition/Transition$EpicenterCallback;Href=../../../reference/android/transition/Transition.EpicenterCallback.html or null if no callback exists.
[read-only]
InterpolatorITimeInterpolator. Returns the interpolator set on this transition.
[read-only]
NameString. Returns the name of this Transition.
PathMotionPathMotion. Returns the algorithm object used to interpolate along two dimensions.
PropagationTransitionPropagation. Returns the TransitionPropagation used to calculate Animator start delays.
[read-only]
StartDelayInt64. Returns the startDelay set on this transition.
[read-only]
TargetIdsIList<Java.Lang.Integer>. Returns the list of target IDs that this transition limits itself to tracking and animating.
[read-only]
TargetNamesIList<string>. Returns the list of target transitionNames that this transition limits itself to tracking and animating.
[read-only]
TargetsIList<Android.Views.View>. Returns the list of target views that this transition limits itself to tracking and animating.
[read-only]
TargetTypesIList<Java.Lang.Class>. Returns the list of target transitionNames that this transition limits itself to tracking and animating.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

AddListener(Transition+ITransitionListener) : Transition
Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.
AddTarget(View) : Transition
Sets the target view instances that this Transition is interested in animating.
AddTarget(Class) : Transition
Adds the Class of a target view that this Transition is interested in animating.
AddTarget(Int32) : Transition
Adds the id of a target view that this Transition is interested in animating.
AddTarget(String) : Transition
Adds the transitionName of a target view that this Transition is interested in animating.
CanRemoveViews() : Boolean
abstract
CaptureEndValues(TransitionValues)
Captures the values in the end scene for the properties that this transition monitors.
abstract
CaptureStartValues(TransitionValues)
Captures the values in the start scene for the properties that this transition monitors.
Clone() : Transition
Creates and returns a copy of this Object.
CreateAnimator(ViewGroup, TransitionValues, TransitionValues) : Animator
This method creates an animation that will be run for this transition given the information in the startValues and endValues structures captured earlier for the start and end scenes.
ExcludeChildren(View, Boolean) : Transition
Whether to add the children of given target to the list of target children to exclude from this transition.
ExcludeChildren(Class, Boolean) : Transition
Whether to add the given type to the list of types whose children should be excluded from this transition.
ExcludeChildren(Int32, Boolean) : Transition
Whether to add the children of the given id to the list of targets to exclude from this transition.
ExcludeTarget(View, Boolean) : Transition
Whether to add the given target to the list of targets to exclude from this transition.
ExcludeTarget(Class, Boolean) : Transition
Whether to add the given type to the list of types to exclude from this transition.
ExcludeTarget(Int32, Boolean) : Transition
Whether to add the given id to the list of target ids to exclude from this transition.
ExcludeTarget(String, Boolean) : Transition
Whether to add the given transitionName to the list of target transitionNames to exclude from this transition.
GetEpicenterCallback() : Transition+EpicenterCallback
Returns the callback used to find the epicenter of the Transition.
GetTransitionProperties() : String[]
Returns the set of property names used stored in the TransitionValues object passed into Transition.CaptureStartValues(TransitionValues) that this transition cares about for the purposes of canceling overlapping animations.
GetTransitionValues(View, Boolean) : TransitionValues
This method can be called by transitions to get the TransitionValues for any particular view during the transition-playing process.
RemoveListener(Transition+ITransitionListener) : Transition
Removes a listener from the set listening to this animation.
RemoveTarget(View) : Transition
Removes the given target from the list of targets that this Transition is interested in animating.
RemoveTarget(Class) : Transition
Removes the given target from the list of targets that this Transition is interested in animating.
RemoveTarget(Int32) : Transition
Removes the given targetId from the list of ids that this Transition is interested in animating.
RemoveTarget(String) : Transition
Removes the given targetName from the list of transitionNames that this Transition is interested in animating.
SetDuration(Int64) : Transition
Sets the duration of this transition.
SetEpicenterCallback(Transition+EpicenterCallback)
Sets the callback to use to find the epicenter of a Transition.
SetInterpolator(ITimeInterpolator) : Transition
Sets the interpolator of this transition.
SetMatchOrder(params Int32[])
SetStartDelay(Int64) : Transition
Sets the startDelay of this transition.