container:2号已经存在的布局 --
bottomView:1号将要添加的布局
lp设置要布局大小
bottomView.setLayoutParams(lp);设置将要添加的布局的大小
container.addView(bottomView);将布局加入到2号布局中
详细代码:
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
LinearLayout bottomView = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.teach_class_main_bottom_layout, null);
bottomView.setLayoutParams(lp);
llPublish = (LinearLayout) bottomView.findViewById(R.id.ll_publish);
llPublish.setOnClickListener(this);
container.addView(bottomView);