0

I found this documentation on the PatternPathMotion:

https://developer.android.com/reference/android/transition/PatternPathMotion.html

and have questions of how to use it. If someone could show me where to find a tutorial or example or both, that would help too.

I have a feeling that this is what I need for a transition I want to do, but I need to know more about it, and how to create it.

Thanks

btelman96
  • 413
  • 4
  • 11

1 Answers1

1

I don't have a specific example, but I can explain how to use it. In your transition, you call setPathMotion:

Path path = new Path();
path.moveTo(0, 0);
path.quadTo(0.5f, 0, 1, 1); // Quadratic Bezier
PatternPathMotion pathMotion = new PathMotion(path);
ChangeBounds changeBounds = new ChangeBounds();
changeBounds.setPathMotion(pathMotion);

This sets up a curved motion that the transition will travel along. The path from 0, 0 to 1, 1 will be rotated and stretched to fit the two points along which the ChangeBounds will travel. You can set up any non-zero delta path (the start and end points can't be the same) and PatternMotion will rotate and stretch it to make the start and end of the path match the two points. In my case, I used a Bezier curve, so any motion will have a curve to the right, as if the View were a curve ball moving from the start to the end position. But you could make something as silly as a spiral or as simple as a straight line.

You can also set it up in XML instead of code.

George Mount
  • 20,708
  • 2
  • 73
  • 61