I have a relative layout built from XML.
I am capturing the onTouchEvent.
When I touch the screen anywhere except over the TableLayout or ImageButton
the MotionEvent.ACTION_DOWN and MotionEvent.ACTION_MOVE
events work fine.
Any suggestions as to how to make the onTouchEvent() work on the TableLayout
and ImageButton views?
The purpose of the exercise was to have a drag method working over the relative layout,
nothing I have read suggests it is possible unfortunately.
Maybe manipulating the layout_margin values?
I was contemplating a transparent canvas overlay but haven't figured that out yet.
Code snippets below
XML
<RelativeLayout
xmlns:android="
http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="left"
android:background="@drawable/yellowbackground">
<ImageButton
android:id="@+id/back_butt"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_width="40dp"
android:layout_height="36dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:clickable = "true"
android

nClick="additionClickHandler"
android:src="@drawable/back_button"
android:background="@null"
></ImageButton>
<ImageView
android:id="@+id/r2c2"
android:layout_centerInParent="true"
android:layout_width="55dp"
android:layout_height="55dp"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/four"
android:background="@null"
>
</ImageView>
.....more image views here
<TableLayout
xmlns:android="
http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_alignParentTop="true"
>
<TableRow>
<ImageView
android:id="@+id/imageB1"
android:maxWidth="47dp"
android

adding="1dp"
android:layout_width="wrap_content"
android:layout_height="47dp"
android:clickable = "true"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/one"
android:background="@drawable/buttonbg"
></ImageView>
<ImageButton
android:id="@+id/imageB2"
android:maxWidth="47dp"
..........
android:src="@drawable/two"
android:background="@drawable/buttonbg"
></ImageButton>
<ImageButton
android:id="@+id/imageB3"
android:maxWidth="47dp"
..............
android:src="@drawable/three"
android:background="@drawable/buttonbg"
></ImageButton>
</TableRow>
</TableLayout>
</RelativeLayout>
JAVA
@Override
public boolean onTouchEvent(MotionEvent ev) {
final int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN: {
final float x = ev.getX();
final float y = ev.getY();
// Remember where we started
mLastTouchX = x;
mLastTouchY = y;
Log.d(TAG, "Coords: x=" + x + ",y=" + y);
break;
}
case MotionEvent.ACTION_MOVE: {
final float x = ev.getX();
final float y = ev.getY();
Log.d(TAG, "moved to: x=" + x + ",y=" + y);
Any help would be great.