Share via


EdgeEffect.OnPullDistance(Single, Single) Method

Definition

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

[Android.Runtime.Register("onPullDistance", "(FF)F", "GetOnPullDistance_FFHandler", ApiSince=31)]
public virtual float OnPullDistance (float deltaDistance, float displacement);
[<Android.Runtime.Register("onPullDistance", "(FF)F", "GetOnPullDistance_FFHandler", ApiSince=31)>]
abstract member OnPullDistance : single * single -> single
override this.OnPullDistance : single * single -> single

Parameters

deltaDistance
Single

Change in distance since the last call. Values may be 0 (no change) to 1.f (full length of the view) or negative values to express change back toward the edge reached to initiate the effect.

displacement
Single

The displacement from the starting side of the effect of the point initiating the pull. In the case of touch this is the finger position. Values may be from 0-1.

Returns

The amount of deltaDistance that was consumed, a number between 0 and deltaDistance.

Attributes

Remarks

A view should call this when content is pulled away from an edge by the user. This will update the state of the current visual effect and its associated animation. The host view should always android.view.View#invalidate() after this and draw the results accordingly. This works similarly to #onPull(float, float), but returns the amount of deltaDistance that has been consumed. If the #getDistance() is currently 0 and deltaDistance is negative, this function will return 0 and the drawn value will remain unchanged.

This method can be used to reverse the effect from a pull or absorb and partially consume some of a motion:

if (deltaY < 0) {
                    float consumed = edgeEffect.onPullDistance(deltaY / getHeight(), x / getWidth());
                    deltaY -= consumed * getHeight();
                    if (edgeEffect.getDistance() == 0f) edgeEffect.onRelease();
                }

Java documentation for android.widget.EdgeEffect.onPullDistance(float, float).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to