Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

ElevationOverlayProvider

public class ElevationOverlayProvider
extends Object

java.lang.Object
   ↳ com.google.android.material.elevation.ElevationOverlayProvider


Utility for calculating elevation overlay alpha values and colors.

Summary

Public constructors

ElevationOverlayProvider(Context context)

Public methods

int calculateOverlayAlpha(float elevation)

Calculates the alpha value, between 0 and 255, that should be used with the elevation overlay color, based on the provided elevation value.

float calculateOverlayAlphaFraction(float elevation)

Calculates the alpha fraction, between 0 and 1, that should be used with the elevation overlay color, based on the provided elevation value.

int compositeOverlay(int backgroundColor, float elevation)

Blends the calculated elevation overlay color with the provided backgroundColor.

int compositeOverlay(int backgroundColor, float elevation, View overlayView)

See compositeOverlay(int, float).

int compositeOverlayIfNeeded(int backgroundColor, float elevation, View overlayView)

See compositeOverlayIfNeeded(int, float).

int compositeOverlayIfNeeded(int backgroundColor, float elevation)

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.

int compositeOverlayWithThemeSurfaceColorIfNeeded(float elevation)

Blends the calculated elevation overlay color (@see #compositeOverlayIfNeeded(int, float)) with the current theme's color int value for R.attr.colorSurface if needed.

int compositeOverlayWithThemeSurfaceColorIfNeeded(float elevation, View overlayView)

See compositeOverlayWithThemeSurfaceColorIfNeeded(float).

float getParentAbsoluteElevation(View overlayView)

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.

int getThemeElevationOverlayColor()

Returns the current theme's color int value for R.attr.elevationOverlayColor.

int getThemeSurfaceColor()

Returns the current theme's color int value for R.attr.colorSurface.

boolean isThemeElevationOverlayEnabled()

Returns the current theme's boolean value for R.attr.elevationOverlayEnabled.

Inherited methods

Public constructors

ElevationOverlayProvider

public ElevationOverlayProvider (Context context)

Parameters
context Context

Public methods

calculateOverlayAlpha

public int calculateOverlayAlpha (float elevation)

Calculates the alpha value, between 0 and 255, that should be used with the elevation overlay color, based on the provided elevation value.

Parameters
elevation float

Returns
int

calculateOverlayAlphaFraction

public float calculateOverlayAlphaFraction (float elevation)

Calculates the alpha fraction, between 0 and 1, that should be used with the elevation overlay color, based on the provided elevation value.

Parameters
elevation float

Returns
float

compositeOverlay

public int compositeOverlay (int backgroundColor, 
                float elevation)

Blends the calculated elevation overlay color with the provided backgroundColor.

An alpha level is applied to the theme's R.attr.elevationOverlayColor by using a formula that is based on the provided elevation value.

Parameters
backgroundColor int

elevation float

Returns
int

compositeOverlay

public int compositeOverlay (int backgroundColor, 
                float elevation, 
                View overlayView)

See compositeOverlay(int, float).

Parameters
backgroundColor int

elevation float

overlayView View

Returns
int

compositeOverlayIfNeeded

public int compositeOverlayIfNeeded (int backgroundColor, 
                float elevation, 
                View overlayView)

See compositeOverlayIfNeeded(int, float).

The absolute elevation of the parent of the provided overlayView will also be factored in when determining the overlay color.

Parameters
backgroundColor int

elevation float

overlayView View

Returns
int

compositeOverlayIfNeeded

public int compositeOverlayIfNeeded (int backgroundColor, 
                float elevation)

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.

Parameters
backgroundColor int

elevation float

Returns
int

compositeOverlayWithThemeSurfaceColorIfNeeded

public int compositeOverlayWithThemeSurfaceColorIfNeeded (float elevation)

Blends the calculated elevation overlay color (@see #compositeOverlayIfNeeded(int, float)) with the current theme's color int value for R.attr.colorSurface if needed.

Parameters
elevation float

Returns
int

compositeOverlayWithThemeSurfaceColorIfNeeded

public int compositeOverlayWithThemeSurfaceColorIfNeeded (float elevation, 
                View overlayView)

See compositeOverlayWithThemeSurfaceColorIfNeeded(float).

The absolute elevation of the parent of the provided overlayView will also be factored in when determining the overlay color.

Parameters
elevation float

overlayView View

Returns
int

getParentAbsoluteElevation

public float getParentAbsoluteElevation (View overlayView)

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.

Parameters
overlayView View

Returns
float

getThemeElevationOverlayColor

public int getThemeElevationOverlayColor ()

Returns the current theme's color int value for R.attr.elevationOverlayColor.

Returns
int

getThemeSurfaceColor

public int getThemeSurfaceColor ()

Returns the current theme's color int value for R.attr.colorSurface.

Returns
int

isThemeElevationOverlayEnabled

public boolean isThemeElevationOverlayEnabled ()

Returns the current theme's boolean value for R.attr.elevationOverlayEnabled.

Returns
boolean