title: Android 3 - Adding a Fragment to a LinearLayout: fill_parent does not work
body: <p>I am trying to add a fragment programmatically to a LinearLayout, but the fragment does not stretch its content across the whole layouts height. It acts like wrap_content instead of fill_parent.</p>
  
  <p>On the other side the fill_parent works on the fragment's width.
  How can I change this behaviour?</p>
  
  <p>DashboardActivity:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal" &gt;
  
      &lt;fragment
          android:id="@+id/fragment_dashboard"
          android:layout_width="5dp"
          android:layout_height="fill_parent"
          android:layout_marginLeft="20dp"
          android:layout_weight="1"
          android:name="de.upb.cs.ginkgo.tablet.ui.fragments.DashboardFragment" &gt;
          &lt;!-- Preview: layout=@layout/fragment_dashboard --&gt;
          &lt;/fragment&gt;
  
      &lt;LinearLayout
          android:id="@+id/rightfrag"
          android:layout_width="450dp" 
          android:layout_height="fill_parent"
          android:layout_weight="1"
          android:layout_marginTop="10dp"
          android:layout_marginBottom="15dp"
          android:layout_marginRight="10dp" &gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Its onCreate method:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_dashboard);
      //-- Instantiate Fragmentstuff
      FragmentManager fragmentManager = getFragmentManager();
      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
      ActivitystreamFragment asf = new ActivitystreamFragment();
      fragmentTransaction.add(R.id.rightfrag, asf);
      fragmentTransaction.commit();
      } 
  </code></pre>
  
  <p>The ActivitystreamFragment XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_weight="1"&gt;
  
      &lt;ListView
          android:id="@+id/android:list"
          android:layout_width="0dp" 
          android:layout_height="wrap_content"
          android:layout_weight="1"
          android:drawSelectorOnTop="true"
          android:background="@drawable/back_rightfrag"
           &gt;
  &lt;/ListView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And its createView:</p>
  
  <pre><code> public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View root = inflater.inflate(R.layout.fragment_activitystream, null);
          return root;
          }
  </code></pre>