Search code examples
javaandroidxmlrecordgesture

Recording/Playback Gesture in Android


I've done a bit of searching and I don't think this has been asked yet (if it has, then I have been searching with the wrong terminology)

I'm trying to find out how to record touch gestures/actions done on Android touchscreen (with respect to time), then use the path of that gesture as the path for a graphic to follow (using android's tweening capabilities)

I'm also looking to be able to save the animation so that it can be loaded later on or exported as a file.

My thoughts around this are to take the point of touch's (x,y) coordinates and save the pair across a set interval of time. Then the coordinates can be loaded from the file later on for an ImageView (or some other view) to be tweened across the device.

Plus, I figure a method like this could make it cross-compatible on screens of different sizes if I saved the coordinates as percents instead of actual values, they can then be loaded depending on the screen size of the device

My questions are: Am I on the right track? Or would this be an inefficient way of doing it?

If this is the right idea, what is the best way of recording the positions and then using the tweening capabilities to animate the object (or is there a better method than tweening to provide a smooth animation)?

And if not, what would be the suggested solution to my problem?

All answers appreciated!

Bitwize


Solution

  • There is a tool to record gestures in the devloper application examples. You can find on the emulator : GestureBuilder.

    Here is a tutorial about gestures.


    Though, gestures have been provided to be recognized as gestures not like an animation path. But I believe you can extract data from gestures and get the "path" of given single touch gesture. Here is the main class to represent a gesture.

    It has a toPath() method that could be useful to you.