In the Google IO 2013, Google has announced a new version of the Support Library, which includes ViewDragHelper
class.
I saw the docs, but I couldn't find any sample of usage for this class.
For example, a very typical situation: I have a custom view, which extends from FrameLayout
and allows to drag some of the View
s inside. For example, let it be a Button
. I override onTouchEvent()
and onInterceptTouchEvent()
within my custom view, and if the button of the rect contains the touch coordinates and this is not a simple click, then I start to drag.
So, what I must do with ViewDragHelper
to get that? The clicks to the Button
should process correctly.
Here is a good example shows how ViewDragHelper is used. https://github.com/umano/AndroidSlidingUpPanel
Use ViewDragHelper.create()
method to create it. Use the shouldInterceptTouchEvent()
to determine if you should intercept the touch event from child views.
Use smootSlideViewTo()
method to move the child view within your customized view.
Here is a nice post about how to use ViewDragHelper
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With