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?
@filthy_wizard: RelativeLayout is not deprecated. PercentRelativeLayout is deprecated.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With