ViewDragHelper: how to use it?

怎甘沉沦 提交于 2019-11-30 12:02:57

问题


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 Views 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.


回答1:


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.




回答2:


Here is a nice post about how to use ViewDragHelper

  • each-navigation-drawer-hides-a-viewdraghelper


来源:https://stackoverflow.com/questions/17772532/viewdraghelper-how-to-use-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!