EdgeEffectCompat

public final class EdgeEffectCompat
extends Object

java.lang.Object
   ↳ androidx.core.widget.EdgeEffectCompat


Helper for accessing EdgeEffect. This class is used to access EdgeEffect on platform versions that support it. When running on older platforms it will result in no-ops. It should be used by views that wish to use the standard Android visual effects at the edges of scrolling containers.

Summary

Public constructors

EdgeEffectCompat(Context context)

This constructor is deprecated. Use EdgeEffect constructor directly or create(Context, AttributeSet).

Public methods

static EdgeEffect create(Context context, AttributeSet attrs)

Constructs and returns a new EdgeEffect themed using the given context, allowing support for the view attributes.

boolean draw(Canvas canvas)

This method is deprecated. Use EdgeEffect.draw(Canvas) directly.

void finish()

This method is deprecated. Use EdgeEffect.finish() directly.

static float getDistance(EdgeEffect edgeEffect)

Returns the pull distance needed to be released to remove the showing effect.

boolean isFinished()

This method is deprecated. Use EdgeEffect.isFinished() directly.

boolean onAbsorb(int velocity)

This method is deprecated. Use EdgeEffect.onAbsorb(int) directly.

boolean onPull(float deltaDistance)

This method is deprecated. Use onPull(EdgeEffect, float, float).

boolean onPull(float deltaDistance, float displacement)

This method is deprecated. Use EdgeEffect.onPull(float) directly.

static void onPull(EdgeEffect edgeEffect, float deltaDistance, float displacement)

A view should call this when content is pulled away from an edge by the user.

static float onPullDistance(EdgeEffect edgeEffect, float deltaDistance, float displacement)

A view should call this when content is pulled away from an edge by the user.

boolean onRelease()

This method is deprecated. Use EdgeEffect.onRelease() directly.

void setSize(int width, int height)

This method is deprecated. Use EdgeEffect.setSize(int, int) directly.

Inherited methods

Public constructors

EdgeEffectCompat

public EdgeEffectCompat (Context context)

This constructor is deprecated.
Use EdgeEffect constructor directly or create(Context, AttributeSet).

Construct a new EdgeEffect themed using the given context.

Note: On platform versions that do not support EdgeEffect, all operations on the newly constructed object will be mocked/no-ops.

Parameters
context Context: Context to use for theming the effect

Public methods

create

public static EdgeEffect create (Context context, 
                AttributeSet attrs)

Constructs and returns a new EdgeEffect themed using the given context, allowing support for the view attributes.

Parameters
context Context: Context to use for theming the effect

attrs AttributeSet: The attributes of the XML tag that is inflating the view

Returns
EdgeEffect

draw

public boolean draw (Canvas canvas)

This method is deprecated.
Use EdgeEffect.draw(Canvas) directly.

Draw into the provided canvas. Assumes that the canvas has been rotated accordingly and the size has been set. The effect will be drawn the full width of X=0 to X=width, beginning from Y=0 and extending to some factor < 1.f of height.

Parameters
canvas Canvas: Canvas to draw into

Returns
boolean true if drawing should continue beyond this frame to continue the animation

finish

public void finish ()

This method is deprecated.
Use EdgeEffect.finish() directly.

Immediately finish the current animation. After this call isFinished() will return true.

getDistance

public static float getDistance (EdgeEffect edgeEffect)

Returns the pull distance needed to be released to remove the showing effect. It is determined by the onPull(float, float) deltaDistance and any animating values, including from onAbsorb(int) and onRelease(). This can be used in conjunction with onPullDistance(EdgeEffect, float, float) to release the currently showing effect. On Build.VERSION_CODES.R and earlier, this will return 0.

Parameters
edgeEffect EdgeEffect

Returns
float The pull distance that must be released to remove the showing effect or 0 for versions