我想從整個屏幕收集所有可能的接觸。我實現了一個收集MainActivity的接觸
@Override
public boolean onTouchEvent(MotionEvent e)
{
double x = e.getX();
double y = e.getY();
}
但現在我添加了一個TableView中的「場景」,當我點擊它上面的方法不會被調用,因爲TableView中正在吞噬潤色。
黃色區域周圍的一切都是可點擊的,但黃色區域本身不是。我希望它也是可點擊的,基本上我希望整個屏幕區域都是可點擊的,這樣我可以存儲觸摸位置。怎麼做?
編輯: 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>
你在哪裏實施的onTouchEvent以及如何建立你的佈局文件? –
onTouchEvent在MainActivity中,你的意思是「你的佈局文件是如何構建的?」檢查上面的activity_main.xml,我編輯了帖子。 – L3M0L