我想从我的整个屏幕上收集所有可能的触摸。我实施了一个
@Override
public boolean onTouchEvent(MotionEvent e)
{
double x = e.getX();
double y = e.getY();
}
但是现在我在“场景”中添加了一个 TableView,当我点击它时,上面的方法没有被调用,因为 TableView 正在吞噬 Touches。
黄色区域周围的所有内容都是可点击的,但黄色区域本身不可点击。我也希望它是可点击的,基本上我希望整个屏幕区域一直都是可点击的,这样我就可以存储触摸位置。怎么做?
编辑: onTouchEvent 方法在 MainActivity 类中。这是activity_main.xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:shrinkColumns="*"
android:stretchColumns="*" >
<TableRow android:layout_height="wrap_content">
<TextView
android:id="@+id/column1"
android:text="tapcount"
android:layout_height="wrap_content"
/>
</TableRow>
</TableLayout>
</ScrollView>
</LinearLayout>