How To Smoothly Animate A View Up/down Based On A Drag Motion Using Objectanimator?
I created a view that has a MapFragment that occupies the top 1/3 of the screen and a ListView that occupies the bottom 2/3 of the screen. The ListView has a 'handle' directly abov
Solution 1:
Finally fixed the issue after reading Google's Chet Haase's answer to a similar question found here. https://stackoverflow.com/a/14780019/476005
Adjusting a view's margin on every frame is too expensive and will always stutter unless the View you're moving is very simple. So to fix this, I do the following in my OnTouch(...) method:
- On MotionEvent.ACTION_DOWN: Set the View's height to it's maximum height.
- On MotionEvent.ACTION_MOVE: Animate the View's "y" property to the event.getRawY with a duration of 0.
- On MotionEvent.ACTION_UP: Animate the View's "y" property to one of the View's parent's edges. The important thing to do here is to set the height of the View appropriately in onAnimationEnd.
I hope this helps everyone.
Post a Comment for "How To Smoothly Animate A View Up/down Based On A Drag Motion Using Objectanimator?"