Reputation: 1714
I have a RelativeLayout @+id/main_layout
.
Inside the @+id/main_layout
, I have a TextView @+id/txt1
and a RelativeLayout @+id/store
.
For some reason I have to set android:layout_below="@+id/txt1"
to the inner RelativeLayout @+id/store
programmatically. How to do that?
Upvotes: 0
Views: 565
Reputation: 1299
Can you try adding it like this:
RelativeLayout.LayoutParams relativeParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
relativeParams.addRule(RelativeLayout.BELOW, idOfTheViewBelow);
Of course, use parameters (fill parent etc.) which you need!
Edit: Of course, you don't need to create the RelativeLayout
, just instantiate your own, and apply the rules you need!
Upvotes: 3