Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove rule from RelativeLayout before api 17

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?

like image 232
Cote Mounyo Avatar asked Nov 11 '13 21:11

Cote Mounyo


People also ask

Is RelativeLayout deprecated?

@filthy_wizard: RelativeLayout is not deprecated. PercentRelativeLayout is deprecated.

Which attribute or property is specific for RelativeLayout?

Some of the many layout properties available to views in a RelativeLayout include: android:layout_alignParentTop. If "true" , makes the top edge of this view match the top edge of the parent. android:layout_centerVertical.

What is layout_alignParentBottom?

android:layout_alignParentBottom : This attribute is used to place the bottom of the element on the bottom of the container. You can change layout_align parent like top, left, and right. android:layout_centerHorizontal : This attribute is used to center the element horizontally within its parent container.

What is RelativeLayout?

Android RelativeLayout enables you to specify how child views are positioned relative to each other. The position of each view can be specified as relative to sibling elements or relative to the parent.


1 Answers

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.

like image 116
Cote Mounyo Avatar answered Sep 20 '22 18:09

Cote Mounyo