alexvasilkov / GestureViews

ImageView and FrameLayout with gestures control and position animation
Apache License 2.0
2.37k stars 384 forks source link

Animations usage tutorial #126

Closed arnoldozippiex1 closed 4 years ago

arnoldozippiex1 commented 6 years ago

is there any simple tutorial to show how to use animations? i have used GestureViews to create a comic book and want to zoom to different parts of the page. any help will be regarded.

alexvasilkov commented 6 years ago

There are no tutorial unfortunately, but you can explore sample app's code, I tried to split it to small self-contained examples and provided comments in the code.

I don't know your use case, but you can probably look into GestureFrameLayout usage example (layout viewer) or use an images-grid-to-pager animation, similar to recycler to pager sample.

arnoldozippiex1 commented 6 years ago

thanks for your great library and your answer. I managed to use basic animation. but I have another question. how can i setInterpolator for animations? thanks again.

alexvasilkov commented 6 years ago

There is no easy way to do so, you can try to change field under ViewPositionAnimator.positionScroller.interpolator through reflection, though it is not really recommended.

Why do you need to change the interpolator, doesn't AccelerateDecelerateInterpolator work for you?

alashow commented 6 years ago

Spring animations would be an awesome addition

alexvasilkov commented 6 years ago

@alashow Spring animations would be much harder to integrate into existing code, it is not like setting a new interpolator. How exactly you think it can be used in the library? I can see one use case for physics based animation for exit gesture, but do you think there are other places where it can be used as well?

alashow commented 6 years ago

@alexvasilkov I don't know much animations so I thought it could be used as an interpolator? That bouncy at the end of a motion. Like in here or photo viewer opening/closing in Twitter Android app.

alexvasilkov commented 6 years ago

I tried Twitter's official Android app, can't see they use spring animations.

Android's new Spring animation is a separate library (https://developer.android.com/guide/topics/graphics/spring-animation), it is not a standalone interpolator. OvershootInterpolator is close to what you said, but I tried it works quite ugly.

So I'm still unsure how we can use spring animations. I also don't want to depend on the springs library, so it should be optional anyway.

alashow commented 6 years ago

Did you try opening a photo on Twitter? Does it have an animation effect that bounces? I thought they were using rebound for that.

alexvasilkov commented 6 years ago

Yes, I'm trying to open an image in Twitter app, still can't see any spring animation, sorry. Twitter is not in the list of notable users of rebound (can be found here: http://facebook.github.io/rebound/).