ExpandableTransformationBehavior

public abstract class ExpandableTransformationBehavior extends ExpandableBehavior


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

Behaviors should override onCreateExpandedStateChangeAnimation to return an animation

Summary

Public constructors

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

From com.google.android.material.transformation.ExpandableBehavior
ExpandableWidget
findExpandableWidget(CoordinatorLayout parent, View child)
static T
<T extends ExpandableBehavior> from(View view, Class<T> klass)

A utility function to get the ExpandableBehavior attached to the view.

abstract boolean
layoutDependsOn(CoordinatorLayout parent, View child, View dependency)
boolean
onDependentViewChanged(
    CoordinatorLayout parent,
    View child,
    View dependency
)
boolean
onLayoutChild(CoordinatorLayout parent, View child, int layoutDirection)

Public constructors

ExpandableTransformationBehavior

public ExpandableTransformationBehavior()

ExpandableTransformationBehavior

public ExpandableTransformationBehavior(Context context, AttributeSet attrs)

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
View dependency

the com.google.android.material.expandable.ExpandableWidget dependency containing the new expanded state.

View child

the view that should react to the change in expanded state.

boolean expanded

the new expanded state.

boolean isAnimating

whether this state change occurred while a previous state change was still

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 setExpanded is called multiple times with the same value. Upon configuration change, this callback is called with animated set to false.

Parameters
View dependency

the com.google.android.material.expandable.ExpandableWidget dependency containing the new expanded state.

View child

the view that should react to the change in expanded state.

boolean expanded

the new expanded state.

boolean animated

true if setExpanded 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.