remove rule from RelativeLayout before api 17

AndroidAndroid LayoutAndroid Relativelayout

Android Problem Overview


Prior to API 17, how do I remove a rule from a layout? I have a RelativeLayout with a number of children. The RelativeLayout is the main layout of my activity. After adding the rule programmatically using

RelativeLayout.LayoutParams layout = (LayoutParams) theChild.getLayoutParams();
layout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

I need to remove the rule programmatically at some later time. How would I do this assuming earlier API than 17?

Android Solutions


Solution 1 - Android

Ah, I figure it out.

RelativeLayout.LayoutParams layout = (LayoutParams) myChild.getLayoutParams();
layout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);

So there is really no removeRule until API 17.

Solution 2 - Android

Depending on the situation, in my case I created new LayoutParams and then added rules which were needed

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCote MounyoView Question on Stackoverflow
Solution 1 - AndroidCote MounyoView Answer on Stackoverflow
Solution 2 - AndroidTheSecondView Answer on Stackoverflow