9
私は1つのアクティビティでAndroidアプリを持っています。この活動は、このレイアウトを使用しています。AndroidアプリでDrawerLayoutを使用しているときにジェスチャーが動作しない
その後<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>
、私の元に、私はコンストラクタで定義された2つのジェスチャ検出器を持っている:
mDetector = new GestureDetectorCompat(this, new CustomGestureListener());
mScaleDetector = new ScaleGestureDetector(this, new CustomScaleGestureListener());
そして、私はこの方法をonTouchEventオーバーライドしています:
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getPointerCount() > 1) {
this.mScaleDetector.onTouchEvent(event);
} else {
this.mDetector.onTouchEvent(event);
}
return super.onTouchEvent(event);
}
私の問題は、ジェスチャーが検出されないということです(スワイプジェスチャーで引き出しを開くことはできますが)。 drawerlayoutを例えば線形レイアウトに置き換えた場合、原因がナビゲーション・ドロワーであるため、この問題は発生しません。私は間違って何をしていますか?
この問題の解決方法はありますか? – owe
私は@vivoilaソリューションをテストする時間がなかったが、来週にはそれをやる予定だ。私はあなたに何かを教えます。 –
同様の問題が発生しました:http://stackoverflow.com/questions/21040150/drawerlayout-prevents-call-of-mainactivity-ontouchevent#comment31631959_21040150私の質問でアップデートを行う前に、私は@vivoilaのソリューションをテストしましたが、これは私にとってはうまくいかなかったのです。 – owe