Dynamically Changing The Position Of A Button With Respect To Another Button
I had seen a couple of examples for setting the relative position through program (from java) for views in android. But in my particular case i have 2 buttons (which are not views)
Solution 1:
You can use LayoutParams object and add rules to that object as per your requirement. and then setlayoutparam to your button.
For example:
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(80,80); // size of button in dpparams.addRule(RelativeLayout.LEFT_OF, R.id.btnAdd);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
params.setMargins(0, 0, 20, 60);
btnMyLocation.setLayoutParams(params);
Post a Comment for "Dynamically Changing The Position Of A Button With Respect To Another Button"