Waqleh
Waqleh

Reputation: 10161

How to set android:orientation="horizontal" programmatically in RelativeLayout?

How to set android:orientation="horizontal" programatically in RelativeLayout like so:

<RelativeLayout
                android:id="@+id/ID"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >

</RelativeLayout>

This is what I have so far:

RelativeLayout rLayout = new RelativeLayout(getActivity());
LayoutParams layoutParams;
layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
rLayout.setLayoutParams(layoutParams);

Upvotes: 7

Views: 19161

Answers (2)

user2058839
user2058839

Reputation:

As you can see in the docs, there is no orientation argument for RelativeLayout.

Upvotes: 25

MillaresRoo
MillaresRoo

Reputation: 3848

A RelativeLayout layout does not have orientation. Maybe what you need is a LinearLayout.

Upvotes: 3

Related Questions