title: Android button not resizing when put in table programmatically
body: <p>I need to change the size (specifically the height) of a button in an Android app where the button resides in a table and is created programmatically.  I have tried about 20 different approaches and failed miserably.  If I create a button outside the table, I can change the size without a problem, but as soon as it goes in a table, the height stays fixed even though I can change the width.</p>
  
  <p>I have tried creating and using, LinearLayout params, ViewGroup layout params, TableLayout params, etc. and setting their heights either via that constructor (e.g WRAP_CONTENT) or using setHeight().  I have also tried simply calling button.setHeight(). I have changed settings in my xml manifest for the table as well. I have used pixel values and Dpi values. All of this has failed. Here is the basics of what I have so far (just showing a call to b.setHeight()):</p>
  
  <pre><code>TableRow row = new TableRow(getApplicationContext());
  row.setId(counter);
  
  TextView t = new TextView(getApplicationContext());
  t.setText("BLH  " + counter);
  t.setTextColor(Color.BLACK);
  
  //I have also tried table.getContext() in this constructor...
  Button b = new Button(getApplicationContext());
  b.setOnClickListener(new Button.OnClickListener() {
  
  public void onClick(View v) 
  { 
        //blah blah blah
  });
  
  //Convert from pixels to Dpi
  final float scale = getResources().getDisplayMetrics().density;
  int heightDp = (int) (33 * scale + 0.5f);
  int widthDp = (int) (60 * scale + 0.5f);      
  b.setText(R.string.removeButtonText);
  b.setTextSize(12);
  b.setTag(counter);
  b.setHeight(heightDp);
  b.setWidth(widthDp);           
  b.setId(counter);
  
  counter++;
  row.addView(t);
  row.addView(b);
  
  // add the TableRow to the TableLayout
  table.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  </code></pre>
  
  <p>This correctly results in a button being placed in the table, but the height does not change no matter what values I use.  In my xml file, here is what the table declaration looks like:</p>
  
  <pre><code>&lt;TableLayout
   android:id="@+id/myTable"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:padding="20dp" 
   android:stretchColumns="0"&gt;
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p>I have tried messing with stretchColumns and other settings here; again, to no avail.  Does anyone have any idea why I can't change the height of a button added to my table programmatically, but have no problems doing so outside the table? I am sure it is some setting or adjustment that I just haven't found.  Any help is appreciated as I am at my wits end.  Thanks in advance.</p>