Layout orientation in code
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);
You can use like this one:
LinearLayout myll = (LinearLayout) findViewById(R.id.yourLinearLayout);myll.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT));myll.setOrientation(LinearLayout.VERTICAL);
You need to instance LinearLayout. After that you can call setOrientation()
LinearLayout myLayout = ...;myLayout.setLayoutParams(new LayoutParams(LinearLayout.WRAP_CONTENT, LinearLayout.WRAP_CONTENT);myLayout.setOrientation(LinearLayout.VERTICAL);
That should do the job :)
For more infos check the Android API.