title: How to resize the button progmmatically in android
body: <p>I want Ui to be done programmatically ,i am using simple button,and it occupies the full width of screen,how should i be resizing the button width.</p>
  
  <pre><code> public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      //setContentView(R.layout.activity_main);
      TextView label = new TextView(this);  
      label.setText("Hello");  
      label.setTextSize(20);  
      Button but = new Button(this);
  
      but.setText("Click Me");
      but.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
              // Perform action on click
              System.out.println("Button Clicked");
              Intent myIntent = new Intent(v.getContext(), SecondActivity.class);
              startActivityForResult(myIntent, 0);
          }
      });
      LinearLayout ll = new LinearLayout(this);  
      ll.setOrientation(LinearLayout.VERTICAL);  
  
      ll.addView(label);
      ll.addView(but);
      setContentView(ll);  
  
  }
  </code></pre>
  
  <p>Is there any separate layout to which i should be adding this button?Any tutorials regarding deeping understanding of layout programmatically will be useful.</p>
  
  <p>Regards
  Rakesh Shankar.P</p>