因此,我希望能夠使用GestureOverlayView和OnGestureListener識別高級手勢,並且能夠使用GestureDetector檢測雙擊和長按。我有兩個功能在兩個不同的項目中單獨工作。但是,我試圖將它們結合起來,並遇到一些問題。看起來,當我嘗試雙擊/長按時,它不被識別,因爲GestureOverlayView覆蓋了整個屏幕,並且只會識別手勢生成器中定義的高級手勢。有誰知道如何設置GestureOverlayView,以便它可以讓GestureDetector完成它的工作?我的代碼:GestureOverlayView和雙擊
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);\
和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>
提前感謝!
這實際上工作。謝謝 ! – 2015-01-07 23:15:15