区分父布局
- rootLayout = (LinearLayout) findViewById(R.id.test_root_linearlayout);
- LinearLayout.LayoutParams rootLinaerParams = new LinearLayout.LayoutParams(
- 100, 100);
- ViewGroup.LayoutParams rootGroupParams = new LinearLayout.LayoutParams(
- 100, 100);
- RelativeLayout.LayoutParams rootRelativeParams = new RelativeLayout.LayoutParams(
- 100, 100);
- TextView testView = new TextView(this);
- testView.setText("根布局测试动态添加组件并设置其大小");
- testView.setLayoutParams(rootGroupParams);
- rootLayout.addView(testView);