我正在创建一个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>