title: Dynamic UI - How to add 3 linearlayouts into a parent linearlayout
body: <p>I'm having a little bit of trouble with creating a dynamic UI.
  I can get it to work with just one LinearLayout but I have no idea how to add more.</p>
  
  <p>This is what I have now, it's one LinearLayout with 3 buttons.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //setContentView(R.layout.activity_main);
  
          maakLayout();
      }
  
      private void maakLayout() {
          LinearLayout linearLayout = new LinearLayout(this);
          linearLayout.setOrientation(LinearLayout.HORIZONTAL);
          LayoutParams layoutParams = new LayoutParams(
                  ViewGroup.LayoutParams.MATCH_PARENT,
                  ViewGroup.LayoutParams.MATCH_PARENT);
          linearLayout.setLayoutParams(layoutParams);
  
          setContentView(linearLayout);
  
          for (int i = 0; i &lt; 3; i++) {
              Button button = new Button(this);
              button.setText("Test");
              button.setTag(i);
              button.setBackgroundResource(R.drawable.border_red);
  
  
  
              LayoutParams layoutTextParams = new LayoutParams(
                      ViewGroup.LayoutParams.WRAP_CONTENT,
                      ViewGroup.LayoutParams.WRAP_CONTENT);
              // LayoutParams layoutImageParams =
              // new LayoutParams(100,100);
              layoutTextParams.topMargin = 5;
              layoutTextParams.leftMargin = 5;
              layoutTextParams.rightMargin = 5;
              button.setLayoutParams(layoutTextParams);
  
              linearLayout.addView(button);
          }
      }
  </code></pre>
  
  <p>What I need is the following:
  <img src="https://i.stack.imgur.com/R1a3Q.png" alt="What I need">
  And the static XML code for this is the following:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.example.test.MainActivity" &gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_marginRight="5dp"
          android:orientation="vertical" &gt;
  
          &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/border_red"
          android:text="Test" /&gt;
  
          &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/border_red"
          android:text="Test" /&gt;
  
          &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/border_red"
          android:text="Test" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="144dp"
          android:layout_marginRight="5dp"
          android:orientation="vertical" &gt;
  
          &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:background="@drawable/border_blue"
          android:text="Test" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:orientation="vertical" &gt;
  
          &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/border_red"
          android:text="Test" /&gt;
  
          &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/border_red"
          android:text="Test" /&gt;
  
          &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:background="@drawable/border_red"
          android:text="Test" /&gt;
  
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Once I know how to add other linearlayouts I'm good I think, thank you for your help.</p>