title: Margin TableRow
body: <p>I've looked through all the people that have asked the same thing and no one has ever answered correctly the question. For some reason I can't seem to find how to do this.
  I need to add a margin between each of my dynamically made TableRows.
  This is what I have now.
  <img src="https://i.stack.imgur.com/d3NgE.png" alt="Android"></p>
  
  <p>As you can see, the rows are way together, making the GUI not usable for a user.
  The TableLayout is inside a ScrollView.
  This is the code I use to create dynamically the TextView and  the button. I have tried using margins but no luck so far</p>
  
  <pre><code>Display display = getWindowManager().getDefaultDisplay();
      Point size = new Point();
      display.getSize(size);
      int width = size.x;
      int height = size.y;
  
      TableLayout tl = (TableLayout) findViewById(R.id.TableLayout1);
  
      /* Create a new row to be added. */
      TableRow tr = new TableRow(this);
      TableLayout.LayoutParams tableRowParams = new TableLayout.LayoutParams(
              TableLayout.LayoutParams.FILL_PARENT,
              TableLayout.LayoutParams.WRAP_CONTENT);
  
      /* Margin. */
      int leftMargin = 0;
      int topMargin = 200;
      int rightMargin = 0;
      int bottomMargin = 0;
  
      /* Set margins and create new textview. */
      tableRowParams.setMargins(leftMargin, topMargin, rightMargin,
              bottomMargin);
      tr.setLayoutParams(tableRowParams);
      TextView encuestasTextView = new TextView(this);
      encuestasTextView.setText("Esto es una prueba");
      encuestasTextView.setLayoutParams(new TableRow.LayoutParams(
              TableRow.LayoutParams.WRAP_CONTENT,
              TableRow.LayoutParams.WRAP_CONTENT));
  
      tr.addView(encuestasTextView);
  
      Button a = new Button(this);
      a.setText("Abrir encuesta");
      a.setLayoutParams(new TableRow.LayoutParams(width / 3,
              TableRow.LayoutParams.WRAP_CONTENT));
  
      tr.addView(a);
  
      tl.addView(tr, new TableLayout.LayoutParams(
              TableLayout.LayoutParams.FILL_PARENT,
              TableLayout.LayoutParams.WRAP_CONTENT));
  </code></pre>
  
  <p>This is the XML</p>
  
  <pre><code>&lt;RelativeLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/RelativeLayout1"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".Encuestas" &gt;
  
  &lt;ScrollView
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_below="@+id/button1"
  android:layout_weight="1"
  android:scrollbars="vertical" &gt;
  
  &lt;TableLayout
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:stretchColumns="*"
      android:id="@+id/TableLayout1"&gt;
  
  
  &lt;/TableLayout&gt;
  
  
   &lt;/ScrollView&gt;
      &lt;Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"
      android:layout_marginRight="14dp"
      android:layout_marginTop="14dp"
      android:onClick="SyncServer"
      android:text="Sync" /&gt;
    &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>What I'm missing?</p>