title: Get position of ImageView relative to screen programmatically
body: <p>I want to get the position of my <code>ImageView</code> programmatically. By position, I mean the distance in pixel from top of the screen to that <code>ImageView.</code> I have tried every other solution posted in stackoverflow but it's not working for me. My minimum API level is 8.</p>
  
  <p>These are the codes I have tried-</p>
  
  <pre><code>ImageView image = (ImageView) findViewById(R.id.imageView1);
  1) image.getTop();
  
  2) private int getRelativeTop(View myView) {
      if (myView.getParent() == myView.getRootView())
          return myView.getTop();
      else
          return myView.getTop() + getRelativeTop((View) myView.getParent());
  }
  
  3) image.getLocationOnScreen(int[] locaiton);
  </code></pre>