title: Programmatically adding an item to a CardView
body: <p>I have the following XML</p>
  
  <pre><code>&lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:fillViewport="true"&gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"&gt;
  
              &lt;android.support.v7.widget.CardView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="6dp"
                  android:layout_marginRight="6dp"
                  android:layout_marginTop="2dp"
                  app:cardBackgroundColor="@android:color/white"
                  app:cardElevation="2dp"
                  app:cardUseCompatPadding="true"&gt;
  
                      &lt;LinearLayout
                          android:background="@drawable/border_bottom"
                          android:orientation="horizontal"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"&gt;
  
                          &lt;ImageView
                              android:background="@drawable/round"
                              android:id="@+id/image"
                              android:scaleType="fitXY"
                              android:adjustViewBounds="true"
                              android:layout_width="50dp"
                              android:layout_height="50dp"
                              android:padding="2dp"
                              android:layout_marginBottom="5dp"
                              android:layout_marginRight="5dp"
                              android:layout_marginLeft="5dp"/&gt;
  
                          &lt;TextView
                              android:gravity="center|start"
                              android:textStyle="bold"
                              android:text=""
                              android:textSize="16sp"
                              android:id="@+id/tv_billtype"
                              android:layout_width="wrap_content"
                              android:layout_height="match_parent"
                              android:paddingBottom="3dp"/&gt;
                      &lt;/LinearLayout&gt;
  
                      &lt;TableLayout
                          android:background="@drawable/border_bottom"
                          android:id="@+id/table_items"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"/&gt;
              &lt;/android.support.v7.widget.CardView&gt;
  
          &lt;/LinearLayout&gt;
      &lt;/ScrollView&gt;
  </code></pre>
  
  <p>As you can see there are <code>TableLayout</code> and <code>LinearLayout</code> in <code>CardView</code>. When I programmatically add a row in the TableLayout, LinearLayout is below TableLayout and I can't see LinearLayout.<br>
  It's working like <code>FrameLayout</code>. When I remove CardView from my code it work correctly. </p>
  
  <pre><code> TableLayout tableLayout = (TableLayout)findViewById(R.id.table_items);
      tableLayout.invalidate();
      tableLayout.removeAllViews();
      for(int i = 0; i &lt; array.length(); i++) {
          TableRow trFinish = (TableRow) LayoutInflater.from(this).inflate(R.layout.row_billdetail_product, null);
          TextView name, price, quantity;
          name = (TextView)trFinish.findViewById(R.id.tv_name);
          price = (TextView)trFinish.findViewById(R.id.tv_price);
          quantity = (TextView)trFinish.findViewById(R.id.tv_quantity);
  
          JSONObject obj = null;
          obj = array.getJSONObject(i);
          name.setText(obj.getString("Name"));
          price.setText(obj.getString("Price"));
          quantity.setText(obj.getString("Qty") + " x " + obj.getString("PriceUnit"));
  
          tableLayout.addView(trFinish);
      }
  </code></pre>
  
  <p>How to add it correctly?</p>
  
  <p>My Whole XML. Althought not complete.</p>
  
  <pre><code>&lt;LinearLayout
          android:weightSum="10"
          android:orientation="vertical"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
      &lt;ScrollView
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="9"
          android:fillViewport="true"&gt;
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:orientation="vertical"&gt;
  
  
              &lt;android.support.v7.widget.CardView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="6dp"
                  android:layout_marginRight="6dp"
                  android:layout_marginTop="2dp"
                  app:cardBackgroundColor="@android:color/white"
                  app:cardElevation="2dp"
                  app:cardUseCompatPadding="true"&gt;
  
                  &lt;LinearLayout
                      android:orientation="vertical"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"&gt;
                      &lt;LinearLayout
                          android:background="@drawable/border_bottom"
                          android:orientation="horizontal"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"&gt;
                          &lt;ImageView
                              android:background="@drawable/round"
                              android:id="@+id/image"
                              android:scaleType="fitXY"
                              android:adjustViewBounds="true"
                              android:layout_width="50dp"
                              android:layout_height="50dp"
                              android:padding="2dp"
                              android:layout_marginBottom="5dp"
                              android:layout_marginRight="5dp"
                              android:layout_marginLeft="5dp"/&gt;
  
                          &lt;TextView
                              android:gravity="center|start"
                              android:textStyle="bold"
                              android:text=""
                              android:textSize="16sp"
                              android:id="@+id/tv_billtype"
                              android:layout_width="wrap_content"
                              android:layout_height="match_parent"
                              android:paddingBottom="3dp"/&gt;
                      &lt;/LinearLayout&gt;
  
                      &lt;TableLayout
                          android:background="@drawable/border_bottom"
                          android:id="@+id/table_items"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"/&gt; 
  
                      &lt;TableLayout
                          android:background="@drawable/border_bottom"
                          android:id="@+id/table_prices"
                          android:layout_width="match_parent"
                          android:layout_height="wrap_content"/&gt;
  
                  &lt;/LinearLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
  
              &lt;android.support.v7.widget.CardView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="6dp"
                  android:layout_marginRight="6dp"
                  android:layout_marginTop="2dp"
                  app:cardBackgroundColor="@android:color/white"
                  app:cardElevation="2dp"
                  app:cardUseCompatPadding="true"&gt;
  
                  &lt;LinearLayout
                      android:orientation="vertical"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"&gt;
  
                          &lt;TextView
                              android:id="@+id/note_title"
                              android:scaleType="fitXY"
                              android:adjustViewBounds="true"
                              android:layout_width="50dp"
                              android:layout_height="50dp"
                              android:padding="2dp"
                              android:layout_marginBottom="5dp"
                              android:layout_marginRight="5dp"
                              android:layout_marginLeft="5dp"/&gt;
  
                          &lt;TextView
                              android:gravity="center|start"
                              android:textStyle="bold"
                              android:text=""
                              android:textSize="16sp"
                              android:id="@+id/note_contents"
                              android:layout_width="wrap_content"
                              android:layout_height="match_parent"
                              android:paddingBottom="3dp"/&gt;
  
  
                  &lt;/LinearLayout&gt;
              &lt;/android.support.v7.widget.CardView&gt;
  
          &lt;/LinearLayout&gt;
      &lt;/ScrollView&gt;
  
          &lt;LinearLayout
              android:orientation="horizontal"
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="1"&gt;
  
              &lt;!--there is a two button--&gt;
          &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>