因此,我希望能够使用GestureOverlayView和OnGestureListener识别高级手势,并且能够使用GestureDetector检测双击和长按.我在两个不同的项目中分别使用这两个功能.但是,我正在尝试将它们结合起来并遇到一些问题.似乎当我尝试双击/长按时,它不被识别,因为GestureOverlayView覆盖整个屏幕并且只能识别手势生成器中定义的高级手势.有谁知道如何设置GestureOverlayView以便它允许GestureDetector完成它的工作?我的代码:
public class HelloAndroid extends Activity implements OnGesturePerformedListener, OnDoubleTapListener, OnGestureListener {
/** Called when the activity is first created. */
private GestureLibrary mLibrary;
private GestureDetector detector;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (!mLibrary.load()) {
finish();
}
GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
detector = new GestureDetector(this, this);\
Run Code Online (Sandbox Code Playgroud)
和xml ......
<?xml version="1.0" encoding="utf-8"?>
<android.gesture.GestureOverlayView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:visibility="invisible"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
</android.gesture.GestureOverlayView>
Run Code Online (Sandbox Code Playgroud)
提前致谢!
android ×1