Dynamic Relative Layout - Partial code

   
  RelativeLayout rl = new RelativeLayout(this); 
  rl.setBackgroundColor (0xAA000000);

  TextView tv1 = new TextView(this);  
  RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,  
    LayoutParams.WRAP_CONTENT);  
  params1.topMargin = 2;
  tv1.setLayoutParams(params1);  
  tv1.setPadding (10, 10, 10, 10);
  tv1.setWidth(200);
  tv1.setTextColor(Color.WHITE);
  tv1.setText ("Sample Text");  
  tv1.setId(1001);  
  rl.addView(tv1);  

  EditText ed1 = new EditText(this);  
  RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,  
  LayoutParams.WRAP_CONTENT);  
  params2.topMargin = 2;
  params2.addRule(RelativeLayout.BELOW, 1001);  
  ed1.setLayoutParams(params2);  
  ed1.setPadding (10, 10, 10, 10);
  ed1.setWidth(200);
  ed1.setTextColor(Color.BLACK);
  ed1.setBackgroundColor(Color.WHITE);
  ed1.setText("Edit this text");  
  ed1.setId(1002);  
  rl.addView(ed1);    
    
  setContentView(rl);