title: android LinearLayout.LayoutParams add new view
body: <p>i need add a new button and textedit to my LinearLayout.. if I create a new param, the buttons are created over each other.. </p>
  
  <p>my mainactivity:</p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          MyTouchEventView tv = new MyTouchEventView(this);
          setContentView(tv);
          addContentView(tv.btnReset, tv.params);
          addContentView(tv.btnSave, tv.params2); 
      }
  </code></pre>
  
  <p>and MyTouchEventView:</p>
  
  <pre><code>public class MyTouchEventView extends View {
  
      public Button btnReset;
      public Button btnSave;
      public LinearLayout.LayoutParams params;
      public LinearLayout.LayoutParams params2;
  
      public MyTouchEventView(Context context) {
          super(context);
  
          btnReset = new Button(context);
          btnReset.setText("Vymazat platno");
  
          btnSave = new Button(context);
          btnSave.setText("Ulozit");
  
  
          params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                  LinearLayout.LayoutParams.WRAP_CONTENT);
  
          btnReset.setLayoutParams(params);
  
          params2 = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                  LinearLayout.LayoutParams.WRAP_CONTENT);
          params.setMargins(40, 20, 40, 30);
  
          btnSave.setLayoutParams(params2);
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/kvY1T.png" rel="nofollow">http://i.stack.imgur.com/kvY1T.png</a></p>