title: How to design layout programmatically, android?
body: <p><img src="https://i.stack.imgur.com/TQpvp.png" alt="Layout design"></p>
  
  <p>I need to design the above layout through java coding. 
  B1 &amp; B2-> Horizontal linear layout
  B3 &amp; B4-> Horizontal linear layout
  B5 &amp; B6-> Horizontal linear layout
  B7 &amp; B8-> Horizontal linear layout
  B9,B10 &amp; B11-> Horizontal linear layout
  Parent layout is Linearlayout.</p>
  
  <p>This is how I am proceeding</p>
  
  <pre><code>    @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      this.requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
              WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.activity_main);
  
      l = (LinearLayout) findViewById(R.id.mainl); \\PARENT LAYOUT
  
  
      LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      params.gravity = Gravity.CENTER_VERTICAL;
      l1.setLayoutParams(params);
      l2.setLayoutParams(params);
      l3.setLayoutParams(params);
      l5.setLayoutParams(params);
      l1.setOrientation(LinearLayout.HORIZONTAL);
      l2.setOrientation(LinearLayout.HORIZONTAL);
      l3.setOrientation(LinearLayout.HORIZONTAL);
      l5.setOrientation(LinearLayout.HORIZONTAL);
      l1.addView(btn1);
      l1.addView(btn2);
      l2.addView(btn3);
      l2.addView(btn4);
      l3.addView(btn5);
      l3.addView(btn6);
      l5.addView(btn9);
      l5.addView(btn10);
      l5.addView(btn11);
      l.addView(l1);
      l.addView(l2);
      l.addView(l3);
      l.addView(l5);
  
  
  }
  </code></pre>
  
  <p>Though I am not succeeding with my output. Please help me out.</p>