GradientProtection


public class GradientProtection extends ContrastProtection


A type of protection which draws the gradient color.

Summary

Public constructors

Creates an instance associated with a WindowInsetsCompat.Side.

GradientProtection(int side, @ColorInt int color)

Creates an instance associated with a WindowInsetsCompat.Side.

Public methods

@ColorInt int

Gets the color associated with this protection.

float

Gets the scale of the thickness of the protection.

void
setColor(@ColorInt int color)

Sets the color to the protection.

void
setScale(float scale)

Sets the scale of the thickness to the protection.

Inherited methods

From androidx.core.view.insetscontrast.ContrastProtection
void
animateAlpha(float toAlpha)

Animates the alpha from the current value to the specified one.

void
animateInsetsAmount(float toInsetsAmount)

Animates the insets amount from the current value to the specified one.

@FloatRange(from = 0.0, to = 1.0) float

Gets the opacity of the protection.

float

Gets the depth of the protection.

int

Gets the side of this protection.

void
setAlpha(@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
setInsetAmount(@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

public GradientProtection(int side)

Creates an instance associated with a WindowInsetsCompat.Side.

Parameters
int side

the given WindowInsetsCompat.Side.

GradientProtection

public GradientProtection(int side, @ColorInt int color)

Creates an instance associated with a WindowInsetsCompat.Side.

Parameters
int side

the given WindowInsetsCompat.Side.

@ColorInt int color

The color to draw.

Public methods

getColor

public @ColorInt int getColor()

Gets the color associated with this protection.

Returns
@ColorInt int

The color associated with this protection.

getScale

public float getScale()

Gets the scale of the thickness of the protection.

Returns
float

The scale of the thickness.

setColor

public void setColor(@ColorInt int color)

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

Parameters
@ColorInt int color

The color to draw.

setScale

public void setScale(float scale)

Sets the scale of the thickness to the protection.

Parameters
float scale

The scale of the thickness.