Protection
abstract class Protection
ColorProtection |
A type of protection which draws the plain color. |
GradientProtection |
A type of protection which draws the gradient color. |
An abstract class which describes a layer to be placed on the content of a window and underneath the system bar (which has a transparent background) to ensure the readability of the foreground elements (e.g., text, icons, ..., etc) of the system bar.
Concrete derived classes would describe how the protection should be drawn by supplying the Drawable.
The object of this class is stateful, and can only be used by one ProtectionLayout at a time.
Summary
Public constructors |
|---|
Protection(side: Int)Creates an instance associated with a |
Public functions |
|
|---|---|
Unit |
animateAlpha(toAlpha: Float)Animates the alpha from the current value to the specified one. |
Unit |
animateInsetsAmount(toInsetsAmount: Float)Animates the insets amount from the current value to the specified one. |
@FloatRange(from = 0.0, to = 1.0) Float |
getAlpha()Gets the opacity of the protection. |
Float |
Gets the depth of the protection. |
Int |
getSide()Gets the side of this protection. |
Unit |
setAlpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float)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 |
setInsetAmount(insetAmount: @FloatRange(from = 0.0, to = 1.0) Float)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
Protection
Protection(side: Int)
Creates an instance associated with a WindowInsetsCompat.Side.
| Parameters | |
|---|---|
side: Int |
the given |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if the given side is not one of the four sides. |
Public functions
animateAlpha
fun animateAlpha(toAlpha: Float): Unit
Animates the alpha from the current value to the specified one.
Calling setAlpha during the animation will cancel the existing alpha animation.
| Parameters | |
|---|---|
toAlpha: Float |
The alpha that will be animated to. The range is [0, 1]. |
animateInsetsAmount
fun animateInsetsAmount(toInsetsAmount: Float): Unit
Animates the insets amount from the current value to the specified one.
Calling setInsetAmount during the animation will cancel the existing animation of insets amount.
| Parameters | |
|---|---|
toInsetsAmount: Float |
The insets amount that will be animated to. The range is [0, 1]. |
getAlpha
fun getAlpha(): @FloatRange(from = 0.0, to = 1.0) Float
Gets the opacity of the protection. This is a value from 0 to 1, where 0 means the protection is completely transparent and 1 means the protection is completely opaque.
| Returns | |
|---|---|
@FloatRange(from = 0.0, to = 1.0) Float |
The opacity of the protection. |
getInsetAmount
fun getInsetAmount(): Float
Gets the depth of the protection. This is a value from 0 to 1, where 0 means the protection completely inside the window and 1 means the protection is completely outside the window.
| Returns | |
|---|---|
Float |
The depth of the protection. |
getSide
fun getSide(): Int
Gets the side of this protection.
| Returns | |
|---|---|
Int |
the side this protection is associated with. |
setAlpha
fun setAlpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float): Unit
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.
| Parameters | |
|---|---|
alpha: @FloatRange(from = 0.0, to = 1.0) Float |
The opacity of the protection. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if the given alpha is not in a range of [0, 1]. |
setInsetAmount
fun setInsetAmount(insetAmount: @FloatRange(from = 0.0, to = 1.0) Float): Unit
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.
| Parameters | |
|---|---|
insetAmount: @FloatRange(from = 0.0, to = 1.0) Float |
The depth of the protection. |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if the given inset amount is not in a range of [0, 1]. |