ImageView getLocationtOnScreen android
<p>I am trying to get the coordinates of the image on the screen. I currently have an ImageView within an activity. I understand that the getLocationOnScreen() method can only be called once the layout has been created, so calling this method within the oncreate function would return [0,0]. But I do not know how to get this method to return the correct values. I have tried overiding various superclass methods, like the onstart method or the onTouchEvent method and it still returns [0,0] to me. The code I currently have is as follows:</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) 
{
    // Some code here after which ..
    image = (ImageView) findViewById(R.id.imageVfi);        
    image.setImageBitmap(imageData.entrySet().iterator().next().getValue());
}
</code></pre>

<p>Then I have the onStart method which I have overriden</p>

<pre><code>@Override
public void onStart()
{
    super.onStart();        
    image.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            int[] dim = new int[2];
            image.getLocationOnScreen(dim);
            new AlertDialog.Builder(DisplayPicture.this)
            .setIcon(R.drawable.icon)
            .setTitle("Touch coordinates : " +
                    String.valueOf(dim[0]) + "x" + String.valueOf(dim[1]))
            .setPositiveButton("OK", 
                     new DialogInterface.OnClickListener() {   
                 public void onClick(DialogInterface dialog, int which) 
                 {
                     // TODO Auto-generated method stub
                 }
            }).show();
            // image calculations go here
            return true;

        }
    });
}   
</code></pre>

<p>This returns 0X0 to me. Any help is much appreciated.</p>
