getTop()/getLeft for Views in XML file in RelativeLayout doesn't work
<p>My Layout:</p>

<pre><code>&lt;RelativeLayout...&gt;
&lt;Button  
    android:id="@+id/button_1"
    ...
     /&gt;
&lt;Button  
    android:id="@+id/button_2"
    android:layout_toRightOf="@+id/button_1"  
    ...
    /&gt;
...
&lt;/RelativeLayout&gt;
</code></pre>

<p>I want to save the x and y positions of all buttons.</p>

<p>I tried this:</p>

<pre><code>Button b[] = new Button[40];
int parX [] = new int[40];
int parY [] = new int[40];
String temp;
int resID;

for (int i=0;i&lt;=39;i++) 
{
 temp = "id/button_" + String.valueOf(i+1);
 resID = getResources().getIdentifier("com.myapp.test:"+temp, null, null);
 b[i] = (Button) findViewById(resID);
 parX[i] = b[i].getTop();
 parY[i] = b[i].getLeft();
}
</code></pre>

<p>But b[i].getTop() and b[i].getLeft() are always 0.
But it can't be because it is correctly drawn a field of
40 buttons so they must have all different x and y positions.</p>

<p>How can I find out the x/y positions of the buttons of
my xml file?</p>
