title: How to overlay text on image programmatically
body: <p>I have a image placed in the relative layout. How can i place a small image over the background image and two text view side by side next to the image. Any help will be really appreciated. The only thing is I want to do this programmatically. I have tried doing it the following way but for some reason the textview appears on the top left of the screen. I want it appear on the imagebutton.</p>
  
  <pre><code>LinearLayout LinearLayout = new LinearLayout(this); 
  RelativeLayout relativeLayout = new RelativeLayout(this);
  RelativeLayout.LayoutParams relativeLayoutParams;  
  
  Button[] btn = new Button[1];   
  btn[0] = new Button(this);
  btn[0].setId(1);
  btn[0].setGravity(Gravity.CENTER);
  btn[0].setText("text");        
  btn[0].setBackgroundResource(R.drawable.button_grey);
  btn[0].setTextColor(Color.parseColor("#FFFFFF"));
  
  
  relativeLayoutParams = new     RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                                                         RelativeLayout.LayoutParams.WRAP_CONTENT);
  
  relativeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT | RelativeLayout.ALIGN_PARENT_TOP);
  
  relativeLayoutParams.setMargins(20, 20, 15, 15);
  
  relativeLayout.addView(btn[0], relativeLayoutParams);
  
  ImageButton[] Imgbtn = new ImageButton[10];
  Imgbtn[0] = new ImageButton(this);
  Imgbtn[0].setId(2);   
  Imgbtn[0].setBackgroundResource(R.drawable.box_round_corners); 
  Imgbtn[0].setMaxHeight(200);
  Imgbtn[0].setClickable(true);
  
  relativeLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                                                         RelativeLayout.LayoutParams.WRAP_CONTENT);
  
  
  relativeLayoutParams.addRule(RelativeLayout.BELOW,btn[0].getId());
  relativeLayoutParams.height = 100;    
  relativeLayoutParams.setMargins(15, 0, 15, 10);
  Imgbtn[0].setLayoutParams(relativeLayoutParams);
  
  relativeLayout.addView(Imgbtn[0], relativeLayoutParams);
  
  TextView[] txtview = new TextView[10];
  txtview[0] = new TextView(this);
  txtview[0].setId(3);
  txtview[0].setTextColor(Color.parseColor("#000000"));
  txtview[0].setText("text");  
  
  relativeLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
                                                         RelativeLayout.LayoutParams.WRAP_CONTENT);
  </code></pre>
  
  <p>// relativeLayoutParams.addRule(RelativeLayout.ALIGN_LEFT | RelativeLayout.ALIGN_TOP);</p>
  
  <pre><code>relativeLayoutParams.addRule(RelativeLayout.BELOW,Imgbtn[0].getId());
  relativeLayoutParams.height = 20;    
  relativeLayoutParams.setMargins(5, 5, 5, 5);
  txtview[0].setLayoutParams(relativeLayoutParams);
  
  relativeLayout.addView(txtview[0], relativeLayoutParams);
  
  
  android.widget.ScrollView ScrollV = new ScrollView(this); 
  ScrollV.addView( relativeLayout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); 
  addContentView(ScrollV, new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); 
  </code></pre>