Android 12 Developer Preview is here! Try it out, and give us your feedback!

ScaleProvider

public final class ScaleProvider
extends Object implements VisibilityAnimatorProvider

java.lang.Object
   ↳ com.google.android.material.transition.platform.ScaleProvider


A class that configures and is able to provide an Animator that scales a view.

ScaleProvider's constructor optionally takes a growing parameter. By default, this is set to true and will increase the size of the target both when appearing and disappearing. This is useful when pairing two animating targets, one appearing and one disappearing, that should both be either growing or shrinking to create a visual relationship.

Summary

Public constructors

ScaleProvider()
ScaleProvider(boolean growing)

Public methods

Animator createAppear(ViewGroup sceneRoot, View view)

Should return an Animator that animates in the appearing target view.

Animator createDisappear(ViewGroup sceneRoot, View view)

Should return an Animator that animates out the disappearing target view.

float getIncomingEndScale()

The scale x and scale y value which an appearing and growing target will scale to and a disappearing and shrinking target will scale from.

float getIncomingStartScale()

The scale x and scale y value which an appearing and growing target will scale from and a disappearing and shrinking target will scale to.

float getOutgoingEndScale()

The scale x and scale y value which an appearing and shrinking target will scale from and a disappearing and growing target will scale to.

float getOutgoingStartScale()

The scale x and scale y value which an appearing and shrinking target will scale to and a disappearing and growing target will scale from.

boolean isGrowing()

Whether or not this animation's target will grow or shrink in size.

boolean isScaleOnDisappear()

Whether or not a scale animation will be run on this animation's target when disappearing.

void setGrowing(boolean growing)

Set whether or not this animation's target will grow or shrink in size.

void setIncomingEndScale(float incomingEndScale)

Set the scale x and scale y value which an appearing and growing target should scale to and a disappearing and shrinking target should scale from.

void setIncomingStartScale(float incomingStartScale)

Set the scale x and scale y value which an appearing and growing target should scale from and a disappearing and shrinking target should scale to.

void setOutgoingEndScale(float outgoingEndScale)

Set the scale x and scale y value which an appearing and shrinking target should scale from and a disappearing and growing target should scale to.

void setOutgoingStartScale(float outgoingStartScale)

Set the scale x and scale y value which an appearing and shrinking target should scale to and a disappearing and growing target should scale from.

void setScaleOnDisappear(boolean scaleOnDisappear)

Set whether or not a scale animation will be run on this animation's target when disappearing.

Inherited methods

Public constructors

ScaleProvider

public ScaleProvider ()

ScaleProvider

public ScaleProvider (boolean growing)

Parameters
growing boolean

Public methods

createAppear

public Animator createAppear (ViewGroup sceneRoot, 
                View view)

Should return an Animator that animates in the appearing target view.

Parameters
sceneRoot ViewGroup: The root of the transition hierarchy, which can be useful for checking configurations such as RTL

view View: The view that is appearing

Returns
Animator

createDisappear

public Animator createDisappear (ViewGroup sceneRoot, 
                View view)

Should return an Animator that animates out the disappearing target view.

Parameters
sceneRoot ViewGroup: The root of the transition hierarchy, which can be useful for checking configurations such as RTL

view View: The view that is disappearing

Returns
Animator

getIncomingEndScale

public float getIncomingEndScale ()

The scale x and scale y value which an appearing and growing target will scale to and a disappearing and shrinking target will scale from.

Returns
float

getIncomingStartScale

public float getIncomingStartScale ()

The scale x and scale y value which an appearing and growing target will scale from and a disappearing and shrinking target will scale to.

Returns
float

getOutgoingEndScale

public float getOutgoingEndScale ()

The scale x and scale y value which an appearing and shrinking target will scale from and a disappearing and growing target will scale to.

Returns
float

getOutgoingStartScale

public float getOutgoingStartScale ()

The scale x and scale y value which an appearing and shrinking target will scale to and a disappearing and growing target will scale from.

Returns
float

isGrowing

public boolean isGrowing ()

Whether or not this animation's target will grow or shrink in size.

Returns
boolean

isScaleOnDisappear

public boolean isScaleOnDisappear ()

Whether or not a scale animation will be run on this animation's target when disappearing.

Returns
boolean

setGrowing

public void setGrowing (boolean growing)

Set whether or not this animation's target will grow or shrink in size.

Parameters
growing boolean

setIncomingEndScale

public void setIncomingEndScale (float incomingEndScale)

Set the scale x and scale y value which an appearing and growing target should scale to and a disappearing and shrinking target should scale from.

Parameters
incomingEndScale float

setIncomingStartScale

public void setIncomingStartScale (float incomingStartScale)

Set the scale x and scale y value which an appearing and growing target should scale from and a disappearing and shrinking target should scale to.

Parameters
incomingStartScale float

setOutgoingEndScale

public void setOutgoingEndScale (float outgoingEndScale)

Set the scale x and scale y value which an appearing and shrinking target should scale from and a disappearing and growing target should scale to.

Parameters
outgoingEndScale float

setOutgoingStartScale

public void setOutgoingStartScale (float outgoingStartScale)

Set the scale x and scale y value which an appearing and shrinking target should scale to and a disappearing and growing target should scale from.

Parameters
outgoingStartScale float

setScaleOnDisappear

public void setScaleOnDisappear (boolean scaleOnDisappear)

Set whether or not a scale animation will be run on this animation's target when disappearing.

This is useful when using a single ScaleProvider that runs on multiple targets and only appearing targets should be animated.

Parameters
scaleOnDisappear boolean