14

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.

Onik
  • 19,396
  • 14
  • 68
  • 91
812621
  • 773
  • 2
  • 6
  • 20

1 Answers1

35

this code will set it false:

addRule(RelativeLayout.ALIGN_PARENT_RIGHT,0)
812621
  • 773
  • 2
  • 6
  • 20