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

ExpandableTransformationBehavior

public abstract class ExpandableTransformationBehavior
extends ExpandableBehavior

java.lang.Object
   ↳ androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior<android.view.View>
     ↳ com.google.android.material.transformation.ExpandableBehavior
       ↳ com.google.android.material.transformation.ExpandableTransformationBehavior


This class is deprecated.
Use MaterialContainerTransform instead.

Base Behavior for views that can react to an ExpandableWidget's ExpandableWidget.setExpanded(boolean) state changes by transforming the ExpandableWidget into itself.

Behaviors should override onCreateExpandedStateChangeAnimation(View, View, boolean, boolean) to return an animation

Summary

Public constructors

ExpandableTransformationBehavior()
ExpandableTransformationBehavior(Context context, AttributeSet attrs)

Protected methods

abstract AnimatorSet onCreateExpandedStateChangeAnimation(View dependency, View child, boolean expanded, boolean isAnimating)

Creates an AnimatorSet to be played for this expanded state change.

boolean onExpandedStateChange(View dependency, View child, boolean expanded, boolean animated)

Reacts to a change in expanded state.

Inherited methods

Public constructors

ExpandableTransformationBehavior

public ExpandableTransformationBehavior ()

ExpandableTransformationBehavior

public ExpandableTransformationBehavior (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Protected methods

onCreateExpandedStateChangeAnimation

protected abstract AnimatorSet onCreateExpandedStateChangeAnimation (View dependency, 
                View child, 
                boolean expanded, 
                boolean isAnimating)

Creates an AnimatorSet to be played for this expanded state change.

If the new expanded state is true, the dependency should be hidden and the child should be shown.

If the new expanded state is false, the dependency should be shown and the child should be hidden.

Parameters
dependency View: the ExpandableWidget dependency containing the new expanded state.

child View: the view that should react to the change in expanded state.

expanded boolean: the new expanded state.

isAnimating boolean: whether this state change occurred while a previous state change was still

Returns
AnimatorSet

onExpandedStateChange

protected boolean onExpandedStateChange (View dependency, 
                View child, 
                boolean expanded, 
                boolean animated)

Reacts to a change in expanded state. This callback is guaranteed to be called only once even if ExpandableWidget.setExpanded(boolean) is called multiple times with the same value. Upon configuration change, this callback is called with animated set to false.

Parameters
dependency View: the ExpandableWidget dependency containing the new expanded state.

child View: the view that should react to the change in expanded state.

expanded boolean: the new expanded state.

animated boolean: true if ExpandableWidget.setExpanded(boolean) was called, false if restoring from a configuration change.

Returns
boolean true if the Behavior changed the child view's size or position, false otherwise.