LinearLayout is only allowing one view to be added

后端 未结 3 1033
北海茫月
北海茫月 2021-01-24 01:05
  layout = new LinearLayout(this);
            addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));


            Button btn =          


        
3条回答
  •  别那么骄傲
    2021-01-24 01:48

    Enjoy buddy

    layout = new LinearLayout(this); 
    layout.setLayoutParams(new LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    layout.setOrientation(LinearLayout.VERTICAL);
    setContentView(layout);
    layout.setOrientation(LinearLayout.VERTICAL);
    

    Reome this addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    You have not set Oreientation , Default is Horizontal, and you have given width LayoutParams.FILL_PARENT

提交回复
热议问题