title: setVisibility(GONE) view becomes invisible but still occupies space
body: <p>I've got a view that is effectively is a button. Here is its XML layout (add_new.xml)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal"&gt;
      &lt;Button
          android:id="@+id/buttonNew"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/bText" 
          android:onClick="addNew"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>When I set its visibility to GONE like this</p>
  
  <pre><code>v = getActivity().getLayoutInflater().inflate(R.layout.add_new, null);
  v.setVisibility(View.GONE);
  </code></pre>
  
  <p>it disappears but still occupies space. Like this: <img src="https://i.stack.imgur.com/NxAN6.png" alt="enter image description here"> </p>
  
  <p>This button is a header in the <code>ListView</code>, which is defined by this 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="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/porno" &gt;
  
      &lt;ImageView
          android:id="@+id/icon"
          android:layout_width="30dp"
          android:layout_height="40dp"
          android:layout_marginLeft="4dp"
          android:layout_marginRight="10dp"
          android:layout_marginTop="4dp"
          android:src="@drawable/ic_launcher"&gt;
      &lt;/ImageView&gt;
  
      &lt;TextView
          android:id="@+id/label"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@+id/label"
          android:textSize="20dp" &gt;
      &lt;/TextView&gt;
  
  &lt;/LinearLayout&gt; 
  </code></pre>
  
  <p>And I dont want it to occupy an additional list item when its visibility is set to GONE. As it is stated in the documentation. </p>
  
  <blockquote>
    <p>GONE - This view is invisible, and it doesn't take any space for
    layout purposes.</p>
  </blockquote>
  
  <p>Any ideas on how to make it NOT occupy space?</p>
  
  <p>Thanks,
  Dennis xx</p>
  
  <p>P.S. My listview is inside of a FoldersFragment <code>ListFragment</code>and here is the xml of my MainActivity where FoldersFragment is presented</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/foldersFragment"
          android:layout_width="200dip"
          android:layout_height="match_parent"
          class="com.example.fragments.FoldersFragment" &gt;
      &lt;/fragment&gt;
  
      &lt;fragment
          android:id="@+id/detailFragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          class="com.example.fragments.DetailFragment" &gt;
      &lt;/fragment&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>