ViewDragHelper: how to use it?

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

On the Google IO 2013, Google has announced new version of Support Library, which includes ViewDragHelper class. I saw the docs, but I couldn't find any sample of usage this class.

For example, very typical situation: I have custom view, which extends FrameLayout and allows drag some of the View inside. For exmaple, let's it would be Button. I override onTouchEvent() and onInterceptTouchEvent() within my custom view, and if button of the rect contains touch coordinates and this is not simple click, I start drag.

So, what I must to 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



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