Java Ontouchlistener防止滚动

Java Ontouchlistener防止滚动,java,android,scroll,ontouchlistener,Java,Android,Scroll,Ontouchlistener,我正在创建一个android应用程序,其中一个功能是,它允许用户打开PDF,并通过文本到语音自动开始读取文本 我给了用户一个选项,如果他们触摸屏幕上的任何地方,就会停止TTS。问题是,如果我触摸屏幕“停止”TTS;它防止用户滚动,因为每当我的代码检测到触摸屏时,它只是试图执行停止TTS的操作,而不是滚动 我应该不使用onTouchListeners,还是有其他方法可以解决这个问题 pdfView.setOnTouchListener(new View.OnTouchListener() {

我正在创建一个android应用程序,其中一个功能是,它允许用户打开PDF,并通过文本到语音自动开始读取文本

我给了用户一个选项,如果他们触摸屏幕上的任何地方,就会停止TTS。问题是,如果我触摸屏幕“停止”TTS;它防止用户滚动,因为每当我的代码检测到触摸屏时,它只是试图执行停止TTS的操作,而不是滚动

我应该不使用onTouchListeners,还是有其他方法可以解决这个问题

pdfView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            myTTS.stop();
            return true;//always return true to consume event
        }
    });
然后在我的XML文件中:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="true"
    android:focusable="true"
    android:focusableInTouchMode="true"
    tools:context=".pdfViewer">

    <com.github.barteksc.pdfviewer.PDFView
        android:id="@+id/pdf_viewer"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </com.github.barteksc.pdfviewer.PDFView>

</RelativeLayout>