ViewDragHelper:如何使用它? [英] ViewDragHelper: how to use it?

查看:167
本文介绍了ViewDragHelper:如何使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在谷歌IO 2013年,谷歌已经宣布支持库,其中包括 ViewDragHelper 类的新版本。 我看到了文档,但我找不到的使用同类的样本。

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.

例如,很典型的情况:我有自定义视图,它扩展的FrameLayout,并允许拖动一些查看里面。对于〔实施例,让我们这将是按钮。我重写的onTouchEvent() onInterceptTouchEvent()在我的自定义视图,如果矩形的按钮包含触摸坐标这不是简单的点击,我开始拖。

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.

所以,我必须做的 ViewDragHelper 来获取?在点击该按钮应正确处理。

So, what I must to do with ViewDragHelper to get that? The clicks to the Button should process correctly.

推荐答案

下面是一个很好的例子,说明如何ViewDragHelper使用。 <一href="https://github.com/umano/AndroidSlidingUpPanel">https://github.com/umano/AndroidSlidingUpPanel

Here is a good example shows how ViewDragHelper is used. https://github.com/umano/AndroidSlidingUpPanel

使用ViewDragHelper.create()方法来创建它。使用shouldInterceptTouchEvent以确定是否应该从孩子的意见拦截触摸事件。 使用smootSlideViewTo方法在自定义视图中移动子视图。

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.

这篇关于ViewDragHelper:如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆