ViewDragHelper (VHD)
Ivan Kocijan
Overview
•What isVHD?	

•How to use it?	

•Example
What isVHD
• VDH is a class in Android SupportV4 library	

• It’s used for writing customViewGroups	

• Offers useful operations for allowing user to drag
views around the screen	

• Youtube application uses it to maximize video from
a small box in corner to fullscreen
How to use it
In order to use VDH you will have to:
• Create customView by extendingViewGroup	

• CreateVDH instance	

• ImplementVDH callback	

• Make sure thatVDH handles touch events 	

• Add your customView to XML file
How to use it
1. Create custom view
How to use it
2. CreateViewDragHelper instance
How to use it
4. ImplementVHD callbacks
How to use it
3.ViewDragHelper will now handle touch events
How to use it
4. XML layout
Resources
•https://developer.android.com/reference/android/
support/v4/widget/ViewDragHelper.Callback.html	

!
•http://blog.denevell.org/android-viewdraghelper-
example-tutorial.html

Infinum Android Talks #13 - Using ViewDragHelper