# ExpandableBehavior

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/transformation/ExpandableBehavior.java)

*** ** * ** ***


```
public abstract class ExpandableBehavior
```

<br />

Known direct subclasses [ExpandableTransformationBehavior](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableTransformationBehavior)

|---|---|
| `https://developer.android.com/reference/com/google/android/material/transformation/ExpandableTransformationBehavior` | **This class is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform` instead. <br /> |

Known indirect subclasses [FabTransformationBehavior](https://developer.android.com/reference/com/google/android/material/transformation/FabTransformationBehavior), [FabTransformationScrimBehavior](https://developer.android.com/reference/com/google/android/material/transformation/FabTransformationScrimBehavior), [FabTransformationSheetBehavior](https://developer.android.com/reference/com/google/android/material/transformation/FabTransformationSheetBehavior)

|---|---|
| `https://developer.android.com/reference/com/google/android/material/transformation/FabTransformationBehavior` | **This class is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform` instead. <br /> |
| `https://developer.android.com/reference/com/google/android/material/transformation/FabTransformationScrimBehavior` | **This class is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform` instead. <br /> |
| `https://developer.android.com/reference/com/google/android/material/transformation/FabTransformationSheetBehavior` | **This class is deprecated.** Use `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform` instead. <br /> |

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> Use `https://developer.android.com/reference/com/google/android/material/transition/MaterialContainerTransform` instead.

Base Behavior for views that can react to an `https://developer.android.com/reference/com/google/android/material/expandable/ExpandableWidget`'s `https://developer.android.com/reference/com/google/android/material/expandable/ExpandableWidget#setExpanded(boolean)` state changes.

## Summary

| ### Public constructors |
|---|
| `[ExpandableBehavior](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#ExpandableBehavior())()` |
| `[ExpandableBehavior](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#ExpandableBehavior(Context,AttributeSet))(Context context, AttributeSet attrs)` |

| ### Public methods |
|---|---|
| `static T` | `<T extends https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior> [from](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#from(View,java.lang.Class<T>))(View view, https://developer.android.com/reference/java/lang/Class<T> klass)` A utility function to get the `https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior` attached to the `view`. |
| `abstract boolean` | `[layoutDependsOn](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#layoutDependsOn(CoordinatorLayout,View,View))(CoordinatorLayout parent, View child, View dependency)` |
| `boolean` | `[onDependentViewChanged](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#onDependentViewChanged(CoordinatorLayout,View,View))( CoordinatorLayout parent, View child, View dependency )` |
| `boolean` | `[onLayoutChild](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#onLayoutChild(CoordinatorLayout,View,int))(CoordinatorLayout parent, View child, int layoutDirection)` |

| ### Protected methods |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/expandable/ExpandableWidget` | `[findExpandableWidget](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#findExpandableWidget(CoordinatorLayout,View))(CoordinatorLayout parent, View child)` |
| `abstract boolean` | `[onExpandedStateChange](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#onExpandedStateChange(View,View,boolean,boolean))( View dependency, View child, boolean expanded, boolean animated )` Reacts to a change in expanded state. |

## Public constructors

### ExpandableBehavior

```
public [ExpandableBehavior](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#ExpandableBehavior())()
```

### ExpandableBehavior

```
public [ExpandableBehavior](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#ExpandableBehavior(Context,AttributeSet))(Context context, AttributeSet attrs)
```

## Public methods

### from

```
public static T <T extends ExpandableBehavior> [from](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#from(View,java.lang.Class<T>))(View view, Class<T> klass)
```

A utility function to get the `https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior` attached to the `view`.

| Parameters |
|---|---|
| `View view` | The View that the `https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior` is attached to. |
| `https://developer.android.com/reference/java/lang/Class<T> klass` | The expected `https://developer.android.com/reference/java/lang/Class` of the attached `https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior`. |

| Returns |
|---|---|
| `T` | The `https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior` attached to the `view`. |

### layoutDependsOn

```
public abstract boolean [layoutDependsOn](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#layoutDependsOn(CoordinatorLayout,View,View))(CoordinatorLayout parent, View child, View dependency)
```

### onDependentViewChanged

```
public boolean [onDependentViewChanged](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#onDependentViewChanged(CoordinatorLayout,View,View))(
    CoordinatorLayout parent,
    View child,
    View dependency
)
```

### onLayoutChild

```
public boolean [onLayoutChild](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#onLayoutChild(CoordinatorLayout,View,int))(CoordinatorLayout parent, View child, int layoutDirection)
```

## Protected methods

### findExpandableWidget

```
protected ExpandableWidget [findExpandableWidget](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#findExpandableWidget(CoordinatorLayout,View))(CoordinatorLayout parent, View child)
```

### onExpandedStateChange

```
protected abstract boolean [onExpandedStateChange](https://developer.android.com/reference/com/google/android/material/transformation/ExpandableBehavior#onExpandedStateChange(View,View,boolean,boolean))(
    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 `https://developer.android.com/reference/com/google/android/material/expandable/ExpandableWidget#setExpanded(boolean)` is called multiple times with the same value. Upon configuration change, this callback is called with `animated` set to false.

| Parameters |
|---|---|
| `View dependency` | the `https://developer.android.com/reference/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 `https://developer.android.com/reference/com/google/android/material/expandable/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. |