# CoordinatorLayout.AttachedBehavior

# CoordinatorLayout.AttachedBehavior

Artifact:[androidx.coordinatorlayout:coordinatorlayout](https://developer.android.com/jetpack/androidx/releases/coordinatorlayout)  
[View Source](https://cs.android.com/search?q=file:androidx/coordinatorlayout/widget/CoordinatorLayout.java+class:androidx.coordinatorlayout.widget.CoordinatorLayout.AttachedBehavior)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/coordinatorlayout#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/coordinatorlayout/widget/CoordinatorLayout.AttachedBehavior "View this page in Java")

<br />

```
interface CoordinatorLayout.AttachedBehavior
```

<br />

*** ** * ** ***

Defines the default attached[Behavior](https://developer.android.com/reference/kotlin/androidx/coordinatorlayout/widget/CoordinatorLayout.Behavior)of a[View](https://developer.android.com/reference/android/view/View.html)class

When writing a custom view, implement this interface to return the default behavior when used as a direct child of an[CoordinatorLayout](https://developer.android.com/reference/kotlin/androidx/coordinatorlayout/widget/CoordinatorLayout). The default behavior can be overridden using[setBehavior](https://developer.android.com/reference/kotlin/androidx/coordinatorlayout/widget/CoordinatorLayout.LayoutParams#setBehavior(androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior)).

## Summary

|                                                           ### Public functions                                                            |
|-------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [CoordinatorLayout.Behavior](https://developer.android.com/reference/kotlin/androidx/coordinatorlayout/widget/CoordinatorLayout.Behavior) | [getBehavior](https://developer.android.com/reference/kotlin/androidx/coordinatorlayout/widget/CoordinatorLayout.AttachedBehavior#getBehavior())`()` Returns the behavior associated with the matching[View](https://developer.android.com/reference/android/view/View.html)class. |

## Public functions

### getBehavior

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/coordinatorlayout#1.1.0)  

```
fun getBehavior(): CoordinatorLayout.Behavior
```

Returns the behavior associated with the matching[View](https://developer.android.com/reference/android/view/View.html)class.  

|                                                                  Returns                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
| [CoordinatorLayout.Behavior](https://developer.android.com/reference/kotlin/androidx/coordinatorlayout/widget/CoordinatorLayout.Behavior) | The behavior associated with the matching[View](https://developer.android.com/reference/android/view/View.html)class. Must be non-null. |