I have a RelativeLayout with a number of children. The RelativeLayout is the main layout of my activity. I need to add to one of the children the layout value layout_alignParentBottom="true"
. I need to do this programmatically. the link How to set the android property layout_alignParentBottom to a button dynamically is not working for me because, basically, I don't want to have to inflate the RelativeLayout as I already have it at the setContentView(...)
. Any ideas how to do this?
Asked
Active
Viewed 85 times
1

Community
- 1
- 1

Cote Mounyo
- 13,817
- 23
- 66
- 87
-
are you adding the subview with addView on the RelativeLayout viewgroup? – akhalsa Nov 11 '13 at 21:17
-
@akhalsa I figured it out. – Cote Mounyo Nov 11 '13 at 21:20
1 Answers
0
I figured it out:
RelativeLayout.LayoutParams layout = (LayoutParams) theChild.getLayoutParams();
layout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

Cote Mounyo
- 13,817
- 23
- 66
- 87