ElevationOverlayProvider

Utility for calculating elevation overlay alpha values and colors.

Constructors

Link copied to clipboard
constructor(@NonNull context: Context)
constructor(elevationOverlayEnabled: Boolean, @ColorInt elevationOverlayColor: Int, @ColorInt elevationOverlayAccentColor: Int, @ColorInt colorSurface: Int, displayDensity: Float)

Functions

Link copied to clipboard
open fun calculateOverlayAlpha(elevation: Float): Int
Calculates the alpha value, between 0 and 255, that should be used with the elevation overlay color, based on the provided elevation value.
Link copied to clipboard
Calculates the alpha fraction, between 0 and 1, that should be used with the elevation overlay color, based on the provided elevation value.
Link copied to clipboard
open fun compositeOverlay(@ColorInt backgroundColor: Int, elevation: Float): Int
Blends the calculated elevation overlay color with the provided backgroundColor.
open fun compositeOverlay(@ColorInt backgroundColor: Int, elevation: Float, @NonNull overlayView: View): Int
Link copied to clipboard
open fun compositeOverlayIfNeeded(@ColorInt backgroundColor: Int, elevation: Float): Int
Blends the calculated elevation overlay color (@see #compositeOverlay(int, float)) with the backgroundColor, only if the current theme's R.attr.elevationOverlayEnabled is true and the backgroundColor matches the theme's surface color ( R.attr.colorSurface); otherwise returns the backgroundColor.
open fun compositeOverlayIfNeeded(@ColorInt backgroundColor: Int, elevation: Float, @NonNull overlayView: View): Int
Blends the calculated elevation overlay color (@see #compositeOverlayIfNeeded(int, float)) with the current theme's color int value for R.attr.colorSurface if needed.
Link copied to clipboard
open fun getParentAbsoluteElevation(@NonNull overlayView: View): Float
Returns the absolute elevation of the parent of the provided overlayView, or in other words, the sum of the elevations of all ancestors of the overlayView.
Link copied to clipboard
Returns the current theme's color int value for R.attr.elevationOverlayColor.
Link copied to clipboard
Returns the current theme's color int value for R.attr.colorSurface.
Link copied to clipboard
Returns the current theme's boolean value for R.attr.elevationOverlayEnabled.