My main (highest in hierarchy) layout is a RelativeLayout
. Within it, I am programmatically creating a LinearLayout
. It must have the attribute of being "below" button1
. I know how to use addRule()
to add this to RelativeLayout.LayoutParams
, but LinearLayout.LayoutParams
doesn't have that option.
Asked
Active
Viewed 492 times
0

Wilson
- 8,570
- 20
- 66
- 101
-
refer to [this](http://stackoverflow.com/questions/3277196/can-i-set-androidlayout-below-at-runtime-programmatically) – Manishika Dec 22 '13 at 17:17
2 Answers
2
You can not have below property to LinearLayout. At max you can give orientation type of Vertical or Horizontal. e.g.
LinearLayout layout = /* ... */;
layout.setOrientation(LinearLayout.VERTICAL);
//OR
layout.setOrientation(LinearLayout.HORIZONTAL);

Tabrej Khan
- 894
- 6
- 15
1
Your LinearLayout
is a child to its RelativeLayout
parent. LayoutParams
specify the child's layout within its parent, so in this case the correct LayoutParams
to use for a RelativeLayout
parent is RelativeLayout.LayoutParams
.

laalto
- 150,114
- 66
- 286
- 303