title: Add LinearLayout to ViewGroup
body: <p>I have got custom class which is extending <code>ViewGroup</code> class. Inside it I want to add some views including two buttoons which has to be next to each other. I came up with idea of creating XML file with this view and then add it using addView. Unfortunately it doesn't work out.</p>
  
  <p>My second idea, which I think is better was creating LineraLayout programmatically along with two buttons, setting up all the settings and then adding.</p>
  
  <p>This is the code:</p>
  
  <pre><code>//adding view to view group
  addView(createView(ctx));
  
  //function creating linearlayout and buttons
  private View createView(Context ctx){
          LinearLayout l = new LinearLayout(ctx);
          l.setOrientation(LinearLayout.HORIZONTAL);
          l.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));
          Button btnL = new Button(ctx);
          btnL.setText("Text1");
          Button btnR = new Button(ctx);
          btnR.setText("Text2");
          l.addView(btnL);
          l.addView(btnR);
          return l;
      }
  </code></pre>
  
  <p>The problem is, that I don't see this view now at all. I mean this created from LinearLayout. There is no error in LogCat.</p>
  
  <p>Can someone please tell me what I have to do to add it?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is code for <code>onLayout</code>, I don't have <code>onMeasure</code>:</p>
  
  <pre><code>@Override
      protected void onLayout(boolean changed, int l, int t, int r, int b) {
          int w = getWidth();
          int h = getHeight();
          for (int i = 0; i &lt; NUM_CHILDREN; i++) {
              View v = getChildAt(i);
              int ii = i * 4;
              float fl = w * COORDS[ii] / GRID_WIDTH;
              float ft = h * COORDS[ii + 1] / GRID_HEIGHT;
              float fr = fl + w * COORDS[ii + 2] / GRID_WIDTH;
              float fb = ft + h * COORDS[ii + 3] / GRID_HEIGHT;
              v.layout(Math.round(fl), Math.round(ft), Math.round(fr),
                      Math.round(fb));
          }
      }
  </code></pre>
  
  <p>In general I am just using huge table where I have got info what exact dimensions of given view should be.</p>