What exactly do you want to do? If you want to determine if your EditText is affected, add OnTouchListener to EditText ... or even OnClickListener.
Edit: if you want to detect outside, you can detect a touch event in the containing view, and then if you have an EditText view:
Rect editTextRect = new Rect(); myEditText.getHitRect(editTextRect); if (!editTextRect.contains((int)event.getX(), (int)event.getY())) { Log.d("test", "touch not inside myEditText"); }
Or you add a touch listener both in EditText and in the container and return false in one of the EditText, so it will be intercepted and not be redirected to the parent. This way, all touches that you find in the parent listener will not belong to EditText.
Ix
source share