FrameLayout frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
TextView textView1 = new TextView(this);
textView1.setText("TextView 1");
textView1.setTextSize(20);
textView1.setTextColor(Color.BLACK);
textView1.setGravity(Gravity.CENTER);
TextView textView2 = new TextView(this);
textView2.setText("TextView 2");
textView2.setTextSize(20);
textView2.setTextColor(Color.BLUE);
textView2.setGravity(Gravity.CENTER);
frameLayout.addView(textView1);
frameLayout.addView(textView2);
FrameLayout.LayoutParams layoutParams1 = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
layoutParams1.setMargins(100, 100, 0, 0);
textView1.setLayoutParams(layoutParams1);
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
layoutParams2.setMargins(200, 200, 0, 0);
textView2.setLayoutParams(layoutParams2);
这样,就可以使用多个TextView填充FrameLayout了。