Skip to content

Most visited

Recently visited

navigation

PathInterpolator

public class PathInterpolator
extends BaseInterpolator implements NativeInterpolatorFactory

java.lang.Object
   ↳ android.view.animation.BaseInterpolator
     ↳ android.view.animation.PathInterpolator


An interpolator that can traverse a Path that extends from Point (0, 0) to (1, 1). The x coordinate along the Path is the input value and the output is the y coordinate of the line at that point. This means that the Path must conform to a function y = f(x).

The Path must not have gaps in the x direction and must not loop back on itself such that there can be two points sharing the same x coordinate. It is alright to have a disjoint line in the vertical direction:

     Path path = new Path();
     path.lineTo(0.25f, 0.25f);
     path.moveTo(0.25f, 0.5f);
     path.lineTo(1f, 1f);
 

Summary

Public constructors

PathInterpolator(Path path)

Create an interpolator for an arbitrary Path.

PathInterpolator(float controlX, float controlY)

Create an interpolator for a quadratic Bezier curve.

PathInterpolator(float controlX1, float controlY1, float controlX2, float controlY2)

Create an interpolator for a cubic Bezier curve.

PathInterpolator(Context context, AttributeSet attrs)

Public methods

float getInterpolation(float t)

Using the line in the Path in this interpolator that can be described as y = f(x), finds the y coordinate of the line given t as the x coordinate.

Inherited methods

From class java.lang.Object
From interface com.android.internal.view.animation.NativeInterpolatorFactory
From interface android.animation.TimeInterpolator

Public constructors

PathInterpolator

added in API level 21
PathInterpolator (Path path)

Create an interpolator for an arbitrary Path. The Path must begin at (0, 0) and end at (1, 1).

Parameters
path Path: The Path to use to make the line representing the interpolator.

PathInterpolator

added in API level 21
PathInterpolator (float controlX, 
                float controlY)

Create an interpolator for a quadratic Bezier curve. The end points (0, 0) and (1, 1) are assumed.

Parameters
controlX float: The x coordinate of the quadratic Bezier control point.

controlY float: The y coordinate of the quadratic Bezier control point.

PathInterpolator

added in API level 21
PathInterpolator (float controlX1, 
                float controlY1, 
                float controlX2, 
                float controlY2)

Create an interpolator for a cubic Bezier curve. The end points (0, 0) and (1, 1) are assumed.

Parameters
controlX1 float: The x coordinate of the first control point of the cubic Bezier.

controlY1 float: The y coordinate of the first control point of the cubic Bezier.

controlX2 float: The x coordinate of the second control point of the cubic Bezier.

controlY2 float: The y coordinate of the second control point of the cubic Bezier.

PathInterpolator

added in API level 21
PathInterpolator (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

Public methods

getInterpolation

added in API level 21
float getInterpolation (float t)

Using the line in the Path in this interpolator that can be described as y = f(x), finds the y coordinate of the line given t as the x coordinate. Values less than 0 will always return 0 and values greater than 1 will always return 1.

Parameters
t float: Treated as the x coordinate along the line.

Returns
float The y coordinate of the Path along the line where x = t.

See also:

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.