I created a field of buttons in my XML file:
<RelativeLayout...>
<Button
android:id="@+id/button_1"
...
/>
<Button
android:id="@+id/button_2"
android:layout_toRightOf="@+id/button_1"
...
/>
...
</RelativeLayout>enter code here
Now I want to abolish the XML rule “toRightOf” programmaticaly.
I know how to set rules:
RelativeLayout.LayoutParams params = null;
params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.RIGHT_OF, topIcon.getId());
button_2.setLayoutParams(params);
But I want to DELETE rules I had set in XML file.
How can this be done?
The background of my question: I used an XML file to easily
create field of buttons.
But later I want to drag and drop buttons.
For that I have to delete rules like “toRightOf”.
Otherwise instead of one button a lot of buttons
move if I only want to move one button.
Looking at this question, it cannot be removed but instead you set the value to 0: