title: Adding a dynamic view - Layout gravity problem
body: <p>I am adding a dynamic layout view which looks like this. 
  <a href="https://i.stack.imgur.com/rcd4T.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rcd4T.jpg" alt="Sample View"></a></p>
  
  <p>I am appending this view on button click. Here is the code for this view on button click</p>
  
  <pre><code>public void addDynamicView() {
      RelativeLayout relativeLayout = new RelativeLayout(this);
      relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
  
      LinearLayout lHori = new LinearLayout(this);
      lHori.setOrientation(LinearLayout.HORIZONTAL);
      //lHori.setWeightSum(3);
      lHori.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
  
      LinearLayout lVertical = new LinearLayout(this);
      lVertical.setOrientation(LinearLayout.VERTICAL);
      //lVertical.setWeightSum(2);
      lVertical.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
  
  
      Button button = new Button(this);
      button.setLayoutParams(new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)));
      button.setVisibility(View.VISIBLE);
      button.setText("button");
  
      TextView txtEmpName = new TextView(this);
      txtEmpName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
  
      txtEmpName.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
      txtEmpName.setText("txt1");
  
  
      TextView txtEmpDropTime = new TextView(this);
      txtEmpDropTime.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
      txtEmpDropTime.setText("txt2");
  
      lVertical.addView(txtEmpName);
  
      lVertical.addView(txtEmpDropTime);
  
  
      lHori.addView(lVertical);
      lHori.addView(button);
  
      relativeLayout.addView(lHori);
      linear.addView(relativeLayout);
  }
  </code></pre>
  
  <p>The problem is I want all the buttons to be placed below the <strong>click</strong> button.
  But I get output like this</p>
  
  <p><a href="https://i.stack.imgur.com/arycP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/arycP.png" alt=""></a></p>
  
  <p>How can I place all Button with text Button below the <strong>Click</strong> button?</p>