# GradientProtection

# GradientProtection

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/insets/GradientProtection.java+class:androidx.core.view.insets.GradientProtection)  
Added in[1.16.0](https://developer.android.com/jetpack/androidx/releases/core#1.16.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/view/insets/GradientProtection "View this page in Java")

<br />

```
class GradientProtection : Protection
```

<br />

|---|---|---------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)                                                                |||
| ↳ | [androidx.core.view.insets.Protection](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection)                    ||
|   | ↳ | [androidx.core.view.insets.GradientProtection](https://developer.android.com/reference/kotlin/androidx/core/view/insets/GradientProtection) |

*** ** * ** ***

A type of protection which draws the gradient color.

## Summary

|                                                                                                                                                                                                                                                                             ### Public constructors                                                                                                                                                                                                                                                                              |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [GradientProtection](https://developer.android.com/reference/kotlin/androidx/core/view/insets/GradientProtection#GradientProtection(int))`(side: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Creates an instance associated with a[WindowInsetsCompat.Side](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Side).                                                                                                                                                                                      |
| [GradientProtection](https://developer.android.com/reference/kotlin/androidx/core/view/insets/GradientProtection#GradientProtection(int,int))`(side: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, color: @`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Creates an instance associated with a[WindowInsetsCompat.Side](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Side). |

|                                                                           ### Public functions                                                                           |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `@`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [getColor](https://developer.android.com/reference/kotlin/androidx/core/view/insets/GradientProtection#getColor())`()` Gets the color associated with this protection.                                                                                                                                                                     |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                                                          | [getScale](https://developer.android.com/reference/kotlin/androidx/core/view/insets/GradientProtection#getScale())`()` Gets the scale of the thickness of the protection.                                                                                                                                                                  |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [setColor](https://developer.android.com/reference/kotlin/androidx/core/view/insets/GradientProtection#setColor(int))`(color: @`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets the color to the protection. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                            | [setScale](https://developer.android.com/reference/kotlin/androidx/core/view/insets/GradientProtection#setScale(float))`(scale: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Sets the scale of the thickness to the protection.                                                                     |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.core.view.insets.Protection](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection) |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                          | [animateAlpha](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection#animateAlpha(float))`(toAlpha: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Animates the alpha from the current value to the specified one.                                                                                                                                                                                                                                                 | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                          | [animateInsetsAmount](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection#animateInsetsAmount(float))`(toInsetsAmount: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Animates the insets amount from the current value to the specified one.                                                                                                                                                                                                                    | | `@`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [getAlpha](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection#getAlpha())`()` Gets the opacity of the protection.                                                                                                                                                                                                                                                                                                                                                                                    | | [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                                                                                        | [getInsetAmount](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection#getInsetAmount())`()` Gets the depth of the protection.                                                                                                                                                                                                                                                                                                                                                                          | | [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                            | [getSide](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection#getSide())`()` Gets the side of this protection.                                                                                                                                                                                                                                                                                                                                                                                        | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                          | [setAlpha](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection#setAlpha(float))`(alpha: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Sets the opacity of the protection to a value from 0 to 1, where 0 means the protection is completely transparent and 1 means the protection is completely opaque.                                   | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                                                                                          | [setInsetAmount](https://developer.android.com/reference/kotlin/androidx/core/view/insets/Protection#setInsetAmount(float))`(insetAmount: @`[FloatRange](https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange)`(from = 0.0, to = 1.0) `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Sets the depth of the protection to a value from 0 to 1, where 0 means the protection is completely outside the window and 1 means the protection is completely inside the window. | |

## Public constructors

### GradientProtection

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

```
GradientProtection(side: Int)
```

Creates an instance associated with a[WindowInsetsCompat.Side](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Side).  

|                                     Parameters                                      |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| `side: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the given[WindowInsetsCompat.Side](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Side). |

### GradientProtection

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

```
GradientProtection(side: Int, color: @ColorInt Int)
```

Creates an instance associated with a[WindowInsetsCompat.Side](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Side).  

|                                                                                   Parameters                                                                                    |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
| `side: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                             | the given[WindowInsetsCompat.Side](https://developer.android.com/reference/kotlin/androidx/core/view/WindowInsetsCompat.Side). |
| `color: @`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The color to draw.                                                                                                             |

## Public functions

### getColor

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

```
fun getColor(): @ColorInt Int
```

Gets the color associated with this protection.  

|                                                                                 Returns                                                                                  |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|
| `@`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The color associated with this protection. |

### getScale

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

```
fun getScale(): Float
```

Gets the scale of the thickness of the protection.  

|                                     Returns                                     |
|---------------------------------------------------------------------------------|-----------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The scale of the thickness. |

### setColor

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

```
fun setColor(color: @ColorInt Int): Unit
```

Sets the color to the protection. The pixels farther away from the edge get more transparent.  

|                                                                                   Parameters                                                                                    |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|
| `color: @`[ColorInt](https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt)` `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The color to draw. |

### setScale

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

```
fun setScale(scale: Float): Unit
```

Sets the scale of the thickness to the protection.  

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|-----------------------------|
| `scale: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The scale of the thickness. |