添加到OnGestureListener按钮? [英] Add OnGestureListener to Button?
问题描述
我试图找出如何添加OnGestureListener或一些其他的方式来检测在屏幕上触摸拖动到一个按钮,或可添加到浏览其他一些部件。我一直在试图找出如何一会儿做到这一点,我不能。我已经看到了,并成功地能够把它做的活动。任何人都可以拼出了这一点对我来说,因为我似乎遇到了不少的麻烦,比我以为我会与此有关。谢谢你。
I'm trying to figure out how to add an OnGestureListener or some other way to detect a touch drag across the screen to a button, or some other widget that can be added to a View. I've been trying to figure out how to do this for a while and I can't. I've seen and successfully been able to do it to an activity. Can anyone spell this out for me, because I seem to be having a lot more trouble than I thought I would with this. Thanks.
推荐答案
我假设你已经通过的 http://developer.android.com/resources/articles/gestures.html 。诀窍在于,你可以有 GestureOverlayView
作为另一查看
上面的透明层。然后,您可以跨preT任何手势检测为属于底层查看
。
I'm assuming you've already gone through http://developer.android.com/resources/articles/gestures.html. The trick is that you can have the GestureOverlayView
as a transparent layer on top of another View
. You can then interpret any gestures detected as belonging to the underlying View
.
在文章中,他们表现出你这样的布局:
In the article, they show you a layout like this:
<android.gesture.GestureOverlayView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gestureStrokeType="multiple"
android:eventsInterceptionEnabled="true"
android:orientation="vertical">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</android.gesture.GestureOverlayView>
然后检测可以PTED从ListView控件来间$ P $任何手势。在你的情况你的按钮替换ListView的,你应该准备就绪。
Any gestures detected could then be interpreted as coming from the ListView. In your case replace the ListView with your Button, and you should be all set.
这篇关于添加到OnGestureListener按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!