how to set button position programically?
<p>in my code i crete button two programically how do i set is position to center of screen programically? this is my image of screen <a href="http://imgur.com/7wdyVc6" rel="nofollow">http://imgur.com/7wdyVc6</a>  submit button(button2) is crete just below forloop button how do i set is possition to center of screen???</p>

<pre><code>       ScrollView scroll = new ScrollView(MainActivity1.this);
     scroll.setLayoutParams(new  
   LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,  
       LayoutParams.WRAP_CONTENT));      

     btnLO = new LinearLayout(MainActivity1.this);  
     LinearLayout.LayoutParams paramsLO = new  
      LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
     // button margins
     paramsLO.setMargins(0, 0, 0, 0);
     // button height/width *pixels*
     paramsLO.height = 75;
     paramsLO.width = 75;

     btnLO.setOrientation(LinearLayout.VERTICAL);
     btnLO.setBackgroundColor(5); // not working correctly

     //buttons
     for (i =0;i &lt;reqdata.length;i++)
         {
             LinearLayout li=new LinearLayout(this);
             li.setOrientation(LinearLayout.HORIZONTAL);
             final Button b1 = new Button(MainActivity1.this);
             final ImageView imageView = new ImageView(MainActivity1.this);

             li.addView(b1, paramsLO);        
             li.addView(imageView, paramsLO);
             btnLO.addView(li);

             b1.setText(reqdata[i].getSpinnerText());

             b1.setOnClickListener(new View.OnClickListener() 
                    {
                        public void onClick(View v) 
                        {               


                             imageView1 = imageView;
                             Intent pictureActionIntent = new  
   Intent(MediaStore.ACTION_IMAGE_CAPTURE); 

   pictureActionIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new  
   File(SDCARD_ROOT_PATH + SAVE_PATH_IN_SDCARD,IMAGE_CAPTURE_NAME)));  

   startActivityForResult(pictureActionIntent,CAMERA_PICTURE);
                             b1.setClickable(false);


                          } 

                    });    

         }

     final Button b2 = new Button(MainActivity1.this);
     b2.setText("Submit");
     b2.setOnClickListener(new View.OnClickListener() 
     {
         public void onClick(View v) 
         {                           

             long visitID = dbConnector.saveVisit();

             for (i =0;i &lt;reqdata.length;i++)
             {

  dbConnector.saveVisitDetail(listByte.get(i),visitID,Long.valueOf(reqdata[i]
 .getValue()).longValue());
             }             

         }
     }); 
     btnLO.addView(b2, paramsLO);
     btnLO.setGravity(Gravity.LEFT | Gravity.CENTER_HORIZONTAL);
     scroll.addView(btnLO);

     this.addContentView(scroll, new LayoutParams());

  }
</code></pre>
