Stay organized with collections
Save and categorize content based on your preferences.
OnApplyWindowInsetsListener
interface OnApplyWindowInsetsListener
Listener for applying window insets on a view in a custom way.
Apps may choose to implement this interface if they want to apply custom policy to the way that window insets are treated for a view. If an OnApplyWindowInsetsListener is set, its onApplyWindowInsets
method will be called instead of the View's own onApplyWindowInsets
method. The listener may optionally call the parameter View's onApplyWindowInsets
method to apply the View's normal behavior as part of its own.
Summary
Public methods
onApplyWindowInsets
abstract fun onApplyWindowInsets(
v: View,
insets: WindowInsets
): WindowInsets
When set
on a View, this listener method will be called instead of the view's own onApplyWindowInsets
method.
Parameters |
v |
View: The view applying window insets This value cannot be null . |
insets |
WindowInsets: The insets to apply This value cannot be null . |
Return |
WindowInsets |
The insets supplied, minus any insets that were consumed This value cannot be null . |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# View.OnApplyWindowInsetsListener\n\nAdded in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnApplyWindowInsetsListener\n===========================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/View.OnApplyWindowInsetsListener \"View this page in Java\") \n\n```\ninterface OnApplyWindowInsetsListener\n```\n\n|----------------------------------------------------|\n| [android.view.View.OnApplyWindowInsetsListener](#) |\n\nListener for applying window insets on a view in a custom way.\n\nApps may choose to implement this interface if they want to apply custom policy to the way that window insets are treated for a view. If an OnApplyWindowInsetsListener is set, its [onApplyWindowInsets](#onApplyWindowInsets(android.view.View,%20android.view.WindowInsets)) method will be called instead of the View's own [onApplyWindowInsets](/reference/kotlin/android/view/View#onApplyWindowInsets(android.view.WindowInsets)) method. The listener may optionally call the parameter View's `onApplyWindowInsets` method to apply the View's normal behavior as part of its own.\n\nSummary\n-------\n\n| Public methods ||\n|----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [WindowInsets](/reference/kotlin/android/view/WindowInsets) | [onApplyWindowInsets](#onApplyWindowInsets(android.view.View,%20android.view.WindowInsets))`(`v:` `[View](/reference/kotlin/android/view/View)`, `insets:` `[WindowInsets](/reference/kotlin/android/view/WindowInsets)`)` When [set](/reference/kotlin/android/view/View#setOnApplyWindowInsetsListener(android.view.View.OnApplyWindowInsetsListener)) on a View, this listener method will be called instead of the view's own [onApplyWindowInsets](/reference/kotlin/android/view/View#onApplyWindowInsets(android.view.WindowInsets)) method. |\n\nPublic methods\n--------------\n\n### onApplyWindowInsets\n\nAdded in [API level 20](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onApplyWindowInsets(\n v: View, \n insets: WindowInsets\n): WindowInsets\n```\n\nWhen [set](/reference/kotlin/android/view/View#setOnApplyWindowInsetsListener(android.view.View.OnApplyWindowInsetsListener)) on a View, this listener method will be called instead of the view's own [onApplyWindowInsets](/reference/kotlin/android/view/View#onApplyWindowInsets(android.view.WindowInsets)) method.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------------------------------|\n| `v` | [View](/reference/kotlin/android/view/View): The view applying window insets This value cannot be `null`. |\n| `insets` | [WindowInsets](/reference/kotlin/android/view/WindowInsets): The insets to apply This value cannot be `null`. |\n\n| Return ||\n|-------------------------------------------------------------|---------------------------------------------------------------------------------------|\n| [WindowInsets](/reference/kotlin/android/view/WindowInsets) | The insets supplied, minus any insets that were consumed This value cannot be `null`. |"]]