title: Expand Layout and insert some fields dynamically
body: <p>I want to develop one application in which there will be a button on the screen and after clicking on that button camera will open and it take a photo after that, the layout in which button is there expand and photo comes below to this button.</p>
  
  <p>I show this thing in one application whose screen shoot:</p>
  
  <p><img src="https://i.stack.imgur.com/tkhs8.png" alt="enter image description here"></p>
  
  <p>Here after clicking on photo it capture photo and then this layout expand and photo comes just below like this :-</p>
  
  <p><img src="https://i.stack.imgur.com/Erja2.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/ul4d6.png" alt="enter image description here"></p>
  
  <p>I want same thing in my application.</p>
  
  <p>For this I tried some code which is:-</p>
  
  <p>(Already some fields are there in my application in TableRow which is in TableLayout)</p>
  
  <p>first I create one  tableRow1 (say) after that I create one TableLayout and then one TableRow2 for the button and one TableRow3 for Image. I insert button into tableRow2 and then this tableRow2 into TableLayout and then I insert TableLayout into tableRow1. After capturing photo I insert Image into TableRow3 and then I insert this tableRow3 into TableLayout.</p>
  
  <p>But this code not working, this code also not give any error.</p>
  
  <p>Code:</p>
  
  <pre><code>tableRow1 = new TableRow(this);
  tableRow1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  
  tableLayout = new TableLayout(this);
  tableRow2 = new TableRow(this);
  
  tableLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  tableRow2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  
  buttonPhoto = new Button(this);
  buttonPhoto.setText("Photo");
  buttonPhoto.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  
  tableRow2.addView(buttonPhoto);
  
  tableLayout.addView(tableRow2, new TableLayout.LayoutParams(
              LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  
  tableLayoutMain.addView(tableLayout, new TableLayout.LayoutParams(
              LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  
  
  
  buttonPhoto.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              method1();
          }
      });
  
  public void method1(){
  
      tableRow3 = new TableRow(this);
  
      tableRow3.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  
      imageViewPhoto = new ImageView(this);
      imageViewPhoto.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 110));
      tableRow3.addView(imageViewTakePhoto);
  
      tableLayout.addView(tableRow3, new TableLayout.LayoutParams(
                  LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
  }
  </code></pre>
  
  <p>By using this code I am even not able to see button on the screen.</p>