Layout orientation in code

后端 未结 6 1054
暗喜
暗喜 2020-12-25 09:38

I have this code in my application:

LinearLayout.LayoutParams params =
    new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);

and I

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-25 10:01

    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.

提交回复
热议问题