title: Android: Fragment layout issue
body: <p>For large screens I have two fragments, they shall be either top/bottom or left/right. The problem is that one fragment is taking (almost) all space is taking up by one fragment. For my activity I have two main.xml (one for portrait one for landscape). But they are basically similar (apart from orientation).</p>
  
  <p>main.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="wrap_content"
    android:orientation="vertical" android:id="@+id/frag_cont" &gt;
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>In onCreate I add my fragments to that layout:</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) 
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      OverviewFragment of = new OverviewFragment();
      FragmentTransaction tof = getFragmentManager().beginTransaction();
      tof.add(R.id.frag_cont, of);
      DetailFragmentInitial df = new DetailFragmentInitial();
      tof.add(R.id.frag_cont, df);
      tof.commit();
  
  }
  </code></pre>
  
  <p>The two fragments look kind of similar in terms of onCreateView()</p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
  {   
      return inflater.inflate(R.layout.overview, container, false);
  
  }
  </code></pre>
  
  <p>Finally the two xml files for these fragments look like this, first the smaller fragment:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout 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;ImageView
      android:id="@+id/imageLogo"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/logo"
      android:layout_centerInParent="true" /&gt;
  
      &lt;TextView
      android:id="@+id/textB"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="text"
      android:layout_above="@id/imageLogo" 
      android:layout_centerHorizontal="true"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And now the greedy one taking the space:</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:orientation="vertical"  
  android:layout_weight="10000" &gt;
  
   &lt;ListView
      android:id="@+id/ListView01"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" &gt;
   &lt;/ListView&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I assumed that when I set both layout_weight to 1 then both will take the same amount of space, but even with the setting 1000:1 the bigger one takes about 2/3 of the space. Leaving the weight away will give the bigger fragment all the screen and the other one is not visiable at all. Any ideas?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I followed the approach given below. Much better now in terms of space. On screen rotate the overview fragment (basically list view) is empty, the other fragment is still okay.</p>
  
  <p>In OverviewFragment.java I repopulate the fragment in onActivityCreated():</p>
  
  <pre><code>public void onSaveInstanceState(Bundle bundle)
  {
      bundle.putSerializable("list", mList);
      super.onSaveInstanceState(bundle);
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) 
  {
       super.onActivityCreated(savedInstanceState);
  
      if(savedInstanceState != null)
      {
          mList = (ArrayList&lt;myObject&gt;) savedInstanceState.getSerializable("list");
      }
      else
      {
          mAppList = new ArrayList&lt;myObject&gt;();
          new getApps().execute();
      }
  
      ListView lv = (ListView) getActivity().findViewById(R.id.ListView01);
      lv.setOnItemClickListener(new TableItemSelected());
      mItemAdapter = new ItemAdapterOverview(getActivity().getApplicationContext(), mList);
      lv.setAdapter(mItemAdapter);
  }
  </code></pre>
  
  <p>when rotating the screen the onSaveInstanceState() is called first and then onActivityCreated() <em>twice</em>. The first call the saveInstanceState is not null, the second time it is. Anyway in both cases I should see my list, either build up from scratch or the saved list. Why isn't it and why is that method called twice?</p>