title: Linear Layout creating views but only showing first view
body: <p>I am creating a linear layout programmatically but for some reason I am only able to see the first view. I can see that the space for the other views is being created and that this space is being created correctly. For example it has vertical orientation and holds 6 views. It is creating the space needed for the 6 views, and doing it vertically, but only showing the very first one. </p>
  
  <p>I have seen a lot of answers for this but am unable to get it working. I have tried calling invalidate and postInvalidate on the linear layout and the parent layout but am not getting a refresh. I made sure the code is running on my Main UI thread. I have removed the view right before and then added it but to no avail. I am stuck on this one and can't seem to figure out where my linear layout is going wrong. </p>
  
  <p>Here is some code showing how I've done this before and how I first tried: </p>
  
  <pre><code>     for (int i = 0; i &lt; pdpComparisonAdapter.getCount(); i++) {
              final View item = pdpComparisonAdapter.getView(i, null, null);
              pdpComparisonsLinearLayout.addView(item);
  
      } 
  </code></pre>
  
  <p>Here is the Linear Layout xml:</p>
  
  <pre><code>        &lt;LinearLayout
              android:layout_below="@+id/comparisons_title"
              android:id="@+id/comparisons_linear_layout"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_margin="10dp"
              android:background="#ffffff"
              android:orientation="vertical"/&gt;
  </code></pre>
  
  <p>Here is the view layout that I am trying to add:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;ImageView
          android:src="@drawable/notable_amenity_star"
          android:layout_marginLeft="10dp"
          android:layout_alignParentLeft="true"
          android:id="@+id/comparison_iv"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
  
      &lt;LinearLayout
          android:layout_toRightOf="@+id/comparison_iv"
          android:layout_marginLeft="10dp"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/comparison_value_tv"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
  
          &lt;TextView
              android:id="@+id/comparison_label_tv"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textSize="24sp"/&gt;
  
          &lt;TextView
              android:id="@+id/comparison_explanation_tv"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
  
      &lt;/LinearLayout&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I have also tried working the java code differently like these:</p>
  
  <pre><code>    for (int i = 0; i &lt; pdpComparisonAdapter.getCount(); i++) {
          final View item = pdpComparisonAdapter.getView(i, null, null);
  
          item.setLayoutParams(new RelativeLayout.LayoutParams(
                  RelativeLayout.LayoutParams.MATCH_PARENT,
                  RelativeLayout.LayoutParams.WRAP_CONTENT));
          View oldView = pdpComparisonsLinearLayout.getChildAt(i);
          pdpComparisonsLinearLayout.removeView(oldView);
          pdpComparisonsLinearLayout.addView(item,i);
          pdpComparisonsLinearLayout.getChildAt(i).setVisibility(View.VISIBLE);
      }
      pdpComparisonsLinearLayout.invalidate();
  </code></pre>