Java tutorial
//package com.java2s; import android.graphics.Rect; import android.view.View; public class Main { /** * This method finds location of the view on the screen. * * @param view * @return rect */ public static Rect locateView(View view) { int[] loc_int = new int[2]; if (view == null) return null; try { view.getLocationOnScreen(loc_int); } catch (NullPointerException npe) { // Happens when the view doesn't exist on screen anymore. return null; } Rect location = new Rect(); location.left = loc_int[0]; location.top = loc_int[1]; location.right = location.left + view.getWidth(); location.bottom = location.top + view.getHeight(); return location; } }