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..
Any help would be appreciated.
android.view.ViewGroup.LayoutParams lay = btn1.getLayoutParams();
this lay object hold all the information but i cant get margins from that.
i created my button using following 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);
Hi FlaMM3R
My layout looks like below and you have to use same idea according to your layout.
XML file
Java file
Use same idea in your code and let me know what happened. I hope it will be the answer you are looking.