androidandroid-relativelayoutandroid-layoutparams

How to set layout_alignParentRight="false" programmatically?


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.


Solution

  • this code will set it false:

    addRule(RelativeLayout.ALIGN_PARENT_RIGHT,0)