# 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)

*** ** * ** ***


```
public class GradientProtection extends Protection
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.core.view.insets.Protection](https://developer.android.com/reference/androidx/core/view/insets/Protection) ||
|   | ↳ | [androidx.core.view.insets.GradientProtection](https://developer.android.com/reference/androidx/core/view/insets/GradientProtection) |

*** ** * ** ***

A type of protection which draws the gradient color.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/view/insets/GradientProtection#GradientProtection(int)(int side)` Creates an instance associated with a `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Side`. |
| `https://developer.android.com/reference/androidx/core/view/insets/GradientProtection#GradientProtection(int,int)(int side, @https://developer.android.com/reference/androidx/annotation/ColorInt int color)` Creates an instance associated with a `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Side`. |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int` | `https://developer.android.com/reference/androidx/core/view/insets/GradientProtection#getColor()()` Gets the color associated with this protection. |
| `float` | `https://developer.android.com/reference/androidx/core/view/insets/GradientProtection#getScale()()` Gets the scale of the thickness of the protection. |
| `void` | `https://developer.android.com/reference/androidx/core/view/insets/GradientProtection#setColor(int)(@https://developer.android.com/reference/androidx/annotation/ColorInt int color)` Sets the color to the protection. |
| `void` | `https://developer.android.com/reference/androidx/core/view/insets/GradientProtection#setScale(float)(float scale)` Sets the scale of the thickness to the protection. |

| ### Inherited methods |
|---|
| From [androidx.core.view.insets.Protection](https://developer.android.com/reference/androidx/core/view/insets/Protection) |---|---| | `void` | `https://developer.android.com/reference/androidx/core/view/insets/Protection#animateAlpha(float)(float toAlpha)` Animates the alpha from the current value to the specified one. | | `void` | `https://developer.android.com/reference/androidx/core/view/insets/Protection#animateInsetsAmount(float)(float toInsetsAmount)` Animates the insets amount from the current value to the specified one. | | `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float` | `https://developer.android.com/reference/androidx/core/view/insets/Protection#getAlpha()()` Gets the opacity of the protection. | | `float` | `https://developer.android.com/reference/androidx/core/view/insets/Protection#getInsetAmount()()` Gets the depth of the protection. | | `int` | `https://developer.android.com/reference/androidx/core/view/insets/Protection#getSide()()` Gets the side of this protection. | | `void` | `https://developer.android.com/reference/androidx/core/view/insets/Protection#setAlpha(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float alpha)` 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. | | `void` | `https://developer.android.com/reference/androidx/core/view/insets/Protection#setInsetAmount(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float insetAmount)` 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)

```
public GradientProtection(int side)
```

Creates an instance associated with a `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Side`.

| Parameters |
|---|---|
| `int side` | the given `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Side`. |

### GradientProtection

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

```
public GradientProtection(int side, @ColorInt int color)
```

Creates an instance associated with a `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Side`.

| Parameters |
|---|---|
| `int side` | the given `https://developer.android.com/reference/androidx/core/view/WindowInsetsCompat.Side`. |
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int color` | The color to draw. |

## Public methods

### getColor

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

```
public @ColorInt int getColor()
```

Gets the color associated with this protection.

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int` | The color associated with this protection. |

### getScale

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

```
public float getScale()
```

Gets the scale of the thickness of the protection.

| Returns |
|---|---|
| `float` | The scale of the thickness. |

### setColor

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

```
public void setColor(@ColorInt int color)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int color` | The color to draw. |

### setScale

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

```
public void setScale(float scale)
```

Sets the scale of the thickness to the protection.

| Parameters |
|---|---|
| `float scale` | The scale of the thickness. |