动态添加|动态移除view

RelativeLayout rl = new RelativeLayout(this);
LayoutParams param1 = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
param1.addRule(RelativeLayout.BELOW, 1);//此控件在id为1的控件的下边
TextView tv = new TextView(this);
tv.setText(“文字”);
tv.setId(2);
rl.addView(tv,param1);// 添加View
//rl.removeView (tv);  //移除View

你可能感兴趣的:(动态添加|动态移除view)