I have a very simple layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ImageView
android:id="@+id/board"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/boardmask" />
</LinearLayout>
and a very simple activity:
public class BoardActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.board_activity);
ImageView board = (ImageView) findViewById(R.id.board);
board.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
Log.i("OnTouch", event.getX() + " " + event.getY());
}
return true;
}
});
}
}
The ImageView is about half the screen vertically, and is centered. Can someone explain why a click at the very top or bottom of the screen generates and OnTouch event, it should be out of the ImageView, shouldn't it?
Best regards, and thank you very much.