public View findChildView ( float x , float y ) { final int count = getChildCount ( ) ; if ( y <= 0 && count > 0 ) { return getChildAt ( 0 ) ; } for ( int i = count - 1 ; i >= 0 ; i -- ) { final View child = getChildAt ( i ) ; MarginLayoutParams params = ( MarginLayoutParams ) child . getLayoutParams ( ) ; if ( x >= child . getLeft ( ) - params . leftMargin && x <= child . getRight ( ) + params . rightMargin && y >= child . getTop ( ) - params . topMargin && y <= child . getBottom ( ) + params . bottomMargin ) { return child ; } } return null ; }
Returns the child view under the specific x y coordinate . This method will take margins of the child into account when finding it .