Android ViewFlipper + 手势检测器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2513578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android ViewFlipper + Gesture Detector
提问by Tim
I am using gesture detector to catch "flings" and using a view flipper to change the screen when this happens. Some of my child views contain list views. The the gesture detector wont recognize a swipe if you swipe on the list view. But it will recognize it if it is onTop of TextView's or ImageView's. Is there a way to implement it so that it will recognize the swipes even if they are on top of another view that has a ClickListener?
我正在使用手势检测器来捕捉“flings”并在发生这种情况时使用视图翻转器来更改屏幕。我的一些子视图包含列表视图。如果您在列表视图上滑动,手势检测器将无法识别滑动。但是它会识别它是否在 TextView 或 ImageView 的顶部。有没有办法实现它,以便它能够识别滑动,即使它们位于另一个具有 ClickListener 的视图之上?
回答by Tim
Thank you for your answer. In order to get it working how I wanted it to all I had to add was this:
谢谢您的回答。为了让它按照我想要的方式工作,我必须添加的是:
myList.setOnTouchListener(gestureListener);
myList.setOnTouchListener(gestureListener);
for each of my lists. Now they correctly recognize horizontal swipes to change views, and vertical movement for scrolling the list.
对于我的每个列表。现在他们可以正确识别水平滑动以更改视图,以及垂直移动以滚动列表。
回答by Adam
An example from here: http://android-developers.blogspot.com/2009/10/gestures-on-android-16.html
这里的一个例子:http: //android-developers.blogspot.com/2009/10/gestures-on-android-16.html
<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>
I used this tutorial to look at Android's gesture overlay view. The example which this comes from has a ListView utilizing this GestureOverlayView to scroll the list.
我使用本教程来查看 Android 的手势叠加视图。这来自的示例有一个 ListView,它利用这个 GestureOverlayView 来滚动列表。
回答by hungson175
There is another wonderful solution at android-journey.blogspot
在android-journey.blogspot有另一个很棒的解决方案