title: Programmatically change the width of the Button in android
body: <p>How to change the <code>width</code> of a <code>Button</code> programmatically. I am able to change the <code>height</code> but the width does not change. Following is my code snippet</p>
  
  <pre><code>private void createButton(final String label)
  {
  
      Button button = new Button(this);
      button.setText(label);
  
  
      button.setWidth(10);
      button.setHeight(100);
  
      button.setOnClickListener(new OnClickListener() 
      {
  
          @Override
          public void onClick(View v) 
          {
  
  
          }
      });
      mMenuContainer.addView(button, mMenuItemLayoutParamters);
  
  
  }
  </code></pre>
  
  <p>But the <code>width</code> of the <code>Button</code> occupies the <code>width</code> of the screen.</p>