How to set layout_alignParentRight="false" programmatically?

812621 picture 812621 · Apr 5, 2013 · Viewed 11k times · Source

How to set android:layout_alignParentRight="false" programmatically? I can set it to true by this code but I want to set it to false programmatically:

RelativeLayout.Layoutparams params =
(RelativeLayout.LayoutParams)myView.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
button.setLayoutParams(params);

There is a method removeRule(int) but it's added in (API level 17). I want to use something like this in API level 7 or 8.

Answer

812621 picture 812621 · Apr 5, 2013

this code will set it false:

addRule(RelativeLayout.ALIGN_PARENT_RIGHT,0)