Mam aplikację na Androida z jedną aktywnością. Działalność ta wykorzystuje ten układ:Gesty nie działają podczas używania DrawerLayout w aplikacji Android
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<ListView android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
Następnie, w moim źródle Mam dwa detektory gest zdefiniowane w konstruktorze:
mDetector = new GestureDetectorCompat(this, new CustomGestureListener());
mScaleDetector = new ScaleGestureDetector(this, new CustomScaleGestureListener());
A ja unieważniając onTouchEvent ten sposób:
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getPointerCount() > 1) {
this.mScaleDetector.onTouchEvent(event);
} else {
this.mDetector.onTouchEvent(event);
}
return super.onTouchEvent(event);
}
Moim problemem jest to, że gesty nie są wykrywane (chociaż mogę otworzyć szufladę gestem machnięcia). Ten problem nie występuje, jeśli zastępuję układ kreacji za pomocą, na przykład, układu liniowego, więc przyczyną jest szuflada nawigacji. Co ja robię źle?
Czy otrzymałeś rozwiązanie tego problemu? – owe
Nie miałem czasu, aby przetestować rozwiązanie @vivoila, ale zrobię to w przyszłym tygodniu. Powiem ci coś. –
Mam podobny problem: http://stackoverflow.com/questions/21040150/drawerlayout-prevents-call-of-mainactivity-ontouchevent#comment31631959_21040150. Zanim wprowadziłem aktualizacje w moim pytaniu, testowałem rozwiązanie @vivoila, ale to nie działało dla mnie. – owe