title: how to change the width of a button dynamically
body: <p>I have a method that creates several buttons </p>
  
  <pre><code>public Button[] generaBottoniRisposta(int numeroBottoni, Context context){  
      Button bottoni[]= new Button[numeroBottoni];
  
      /*genero un tot di bottoni in base a numeroBottoni, è necessario avere il context*/
      for(int i=0; i &lt; bottoni.length;i++){           
              bottoni[i] = new Button(context);
              bottoni[i].setId(i);
              bottoni[i].setText(String.valueOf(i+1));
              LayoutParams param = new LinearLayout.LayoutParams(50, 50);
              bottoni[i].setLayoutParams(param);          
          }
  
      return  bottoni;
      }
  </code></pre>
  
  <p>and then another method that add them to a gridlayout.</p>
  
  <p>I want to set the width of those buttons, but i'm not able to do it. </p>
  
  <p>I tried a lot of stuff, <code>setWidth()</code>, <code>setMaxWidth()</code>, <code>invalidate()</code> etc. </p>
  
  <p>Something weird happens. If I try to make the button bigger than its default size it works, if i try  to make the button smaller than its default size it doesn't work! </p>
  
  <p>How should I do? thank you </p>