-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add animation listener #17
Comments
You can track the user actions by adding a new Actor.Builder(SpringSystem.create(), rootView.findViewById(R.id.circle))
.addTranslateMotion(Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT, MotionProperty.X)
.onTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// custom behavior
return true;
}
}) But if you want to actually add new behavior to the animation, you can do something like this:, which will fade the view as the user moves it: final View circle = rootView.findViewById(R.id.circle);
SpringSystem springSystem = SpringSystem.create();
new Actor.Builder(springSystem, rootView.findViewById(R.id.circle))
.addMotion(springSystem.createSpring(), Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT,
0, MotionProperty.X, new SimpleSpringListener() {
@Override
public void onSpringUpdate(Spring spring) {
circle.setAlpha(
1 - 2 * Math.abs((float) spring.getCurrentValue())
/ rootView.getMeasuredWidth());
}
})
.build(); But if you're looking to control the animation, that may get a little complicated since the spring will animate on its own, so you will need to decide whether or not to use the spring's value or your own custom value. |
That's program Errors create your |
Actor walk = new Actor.Builder(SpringSystem.create(), walker) |
rootView.findViewById(R.id.circle)) |
When I create an animation using actor like the following:
new Actor.Builder(SpringSystem.create(), rootView.findViewById(R.id.circle)) .addTranslateMotion(Imitator.TRACK_DELTA, Imitator.FOLLOW_EXACT, MotionProperty.X).build();
I want to add a listener to control the behavior of the animation itself or to track the user actions, ex. when the user touch the view down, up or start moving it.
Note: I want to use this animation to create "Slide to Cancel" function. how can I achieve this function using the above animation.
The text was updated successfully, but these errors were encountered: