Layout orientation in code

后端 未结 6 958
暗喜
暗喜 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 09:43

    A working sample below (it's LayoutParams.WRAP_CONTENT, NOT LinearLayout.WRAP_CONTENT)

    myLayout.setOrientation(LinearLayout.VERTICAL);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    myLayout.setLayoutParams(layoutParams);
    

提交回复
热议问题