private float [ ] getClickCoordinates ( View view ) { int [ ] xyLocation = new int [ 2 ] ; float [ ] xyToClick = new float [ 2 ] ; int trialCount = 0 ; view . getLocationOnScreen ( xyLocation ) ; while ( xyLocation [ 0 ] == 0 && xyLocation [ 1 ] == 0 && trialCount < 10 ) { sleeper . sleep ( 300 ) ; view . getLocationOnScreen ( xyLocation ) ; trialCount ++ ; } final int viewWidth = view . getWidth ( ) ; final int viewHeight = view . getHeight ( ) ; final float x = xyLocation [ 0 ] + ( viewWidth / 2.0f ) ; float y = xyLocation [ 1 ] + ( viewHeight / 2.0f ) ; xyToClick [ 0 ] = x ; xyToClick [ 1 ] = y ; return xyToClick ; }
Returns click coordinates for the specified view .