How to retrieve button information in xml
<p>I am new to android and I want to retrieve button information which is in the XML file. (specifically margin_top and margin_left). After that, i want to dynamically give another margins to that specific button in cording.  I can create new button with new margin but i cant retrieve current button margins..</p>

<p>Any help would be appreciated.</p>

<pre><code>android.view.ViewGroup.LayoutParams lay = btn1.getLayoutParams();
</code></pre>

<p>this lay object hold all the information but i cant get margins from that.</p>

<p>i created my button using following code.</p>

<pre><code>RelativeLayout layout = (RelativeLayout)findViewById(R.id.relativeTest);
        Button btn3 = new Button(TestActivity.this);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
        params.setMargins(200, 200, 200, 200);
        layout.addView(btn3, params);
</code></pre>
