title: View.GONE not working properly
body: <p>I have a GridView of items which i am getting from a web API. I want a "Load more" button to appear once i reach the end of gridview. It works properly until i click the button. The button is supposed to disappear without leaving space but its actually leaving the space.</p>
  
  <p>I get this when i reach the end of the GridView.
  <a href="https://i.stack.imgur.com/q3Klf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q3Klf.png" alt="enter image description here"></a>
  When i click the load more button it disappears which is good but leaves space.
  Below is my piece of code:
  <a href="https://i.stack.imgur.com/FRmbF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FRmbF.png" alt="enter image description here"></a></p>
  
  <pre><code> @Override
  public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
  {
      Log.v("TestInstallationTaskLst", "onScroll");
      int lastItem = firstVisibleItem + visibleItemCount;
      if(lastItem==totalItemCount &amp;&amp; totalItemCount!=0)
      {
          loadMoreButton.setVisibility(View.VISIBLE);
      }
      else
      {
          loadMoreButton.setVisibility(View.GONE);
      }
  }
  
   @Override
  public void onClick(View view)
  {
      if (view == loadMoreButton)
      {
          int offset = assets.size()+1;
          new DownloadTask().execute(searchText, offset, LIMIT);
          loadMoreButton.setVisibility(View.GONE);
      }
  }
  
  &lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  &lt;!-- Main Content View (Must be first child in the DrawerLayout --&gt;
  &lt;FrameLayout
      android:id="@+id/container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@color/dark_grey_color"&gt;
  
      &lt;ProgressBar
          android:id="@+id/progressBar"
          android:layout_width="match_parent"
          android:layout_height="50dp"
          android:indeterminate="true"
          android:layout_gravity="center_vertical" /&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;SearchView android:id="@+id/searchView"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:clickable="true"
              android:queryHint="Search vehicle"/&gt;
  
  
          &lt;GridView
              android:id="@+id/list"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_weight="1"
              android:layout_centerHorizontal="true"
              android:verticalSpacing="10dp"
              android:horizontalSpacing="20dp"
              android:paddingLeft="10dp"
              android:paddingRight="10dp"
              android:paddingTop="10dp"
              android:paddingBottom="10dp"
              android:numColumns="2"&gt;
          &lt;/GridView&gt;
  
          &lt;Button
              android:id="@+id/load_button"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="Load more"/&gt;
  
      &lt;/LinearLayout&gt;
  
  
  &lt;/FrameLayout&gt;
  &lt;!-- Navigation Drawer --&gt;
  &lt;ExpandableListView
      android:id="@+id/gps_menu_drawer"
      android:layout_width="@dimen/navigation_bar_width"
      android:layout_height="match_parent"
      android:layout_gravity="start"
      android:divider="@android:color/transparent"
      android:dividerHeight="0dp"
      android:background="@color/gps_dark_grey"/&gt;
  </code></pre>
  
  <p></p>