这里,通过一个小demo,就可以掌握在布局容器中动态添加控件,以动态添加Button控件为例,添加其他控件同样道理。 1、addView 添加控件到布局容器 2、removeView 在布局容器中删掉已有的控件 TextView textView= new TextView (MainActivity. this ); views .add(textView); textView.setText( "hello world" ); relativeLayout .addView(textView,0);