I have this code in my application:
LinearLayout.LayoutParams params =
new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
and I just want to set the orientation of the LinearLayout to vertical. The equivalent in XML is:
android:orientation="vertical"
How can I do it in the code, without XML?
You can't change LinearLayout
's orientation using its LayoutParams
. It can be done only with a LinearLayout
object.
LinearLayout layout = /* ... */;
layout.setOrientation(LinearLayout.VERTICAL);