//转载一个布局文件,要向这个布局汇总动态添加一个button
RelativeLayout relativeLayout(RelativeLayout)getLayoutInflater().inflate(R.layout.main,null);
//装载要动态添加的按钮布局
Button button = (Button)getLayoutInflater().inflate(R.layout.button,null);
//创建一个LayoutParams对象
RelativeLayoutLayoutParamslayoutParams= new RelativeLayout。LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.RIGHT_OF,R.id.button1);
layoutParams.addRule(RelativeLayout.BELOW,R.id.button);
button.setLayoutParams(layoutParams);
relativeLayout.addView(button);