title: remove header view by scrolling a listview in Android
body: <p>I have a ListView and a RelativeLayout as a header view.
  I want to remove the header, when scroll down and move the listvit to the top of my activity. when listview scroll down, show the header and move listview below the header again. here is my code.
  whats the problem?</p>
  
  <pre><code> &lt;RelativeLayout
          android:background="@color/white"
          android:layout_width="fill_parent"
          android:layout_height="140dp"
          android:layout_below="@+id/rltHeader"
          android:layout_centerHorizontal="true"
          android:id="@+id/rltfullHeaderContainer"&gt;
    &lt;/RelativeLayout&gt;
   &lt;ListView
  
          android:divider="@android:color/transparent"
          android:dividerHeight="16dp"
  
  
          android:paddingLeft="@dimen/brows_btn_right_left_margin"
          android:paddingRight="@dimen/brows_btn_right_left_margin"
  
          android:scrollbarStyle="outsideInset"
  
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
  
          android:id="@+id/listViewServices"
          android:layout_centerHorizontal="true"
          android:layout_below="@+id/rltfullHeaderContainer" /&gt;
  </code></pre>
  
  <p>my java code is:</p>
  
  <pre><code>   float  CurrentVerticalPosition=0,preVerticalPosition;
  
   listViewServices.setOnTouchListener(new View.OnTouchListener()
              {
                  @Override
                  public boolean onTouch(View v, MotionEvent event)
                  {
                      CurrentVerticalPosition = event.getY();
  
                      if (CurrentVerticalPosition &gt; preVerticalPosition + 5)
                      {
                          if (!controlsVisible)
                          {
                              Log.e("scroll Down", "AAA");
                              showViews();
                          }
                      }
                      else if (CurrentVerticalPosition &lt; preVerticalPosition)
                      {
                          if (controlsVisible)
                          {
                              Log.e("scroll UP", "BBB");
                              hideViews();
                          }
                      }
  
                      preVerticalPosition = CurrentVerticalPosition;
                      return false;
                  }
              });
  
  
   private void hideViews()
      {
          controlsVisible=false;
  
          rltHeader.animate().translationY(-rltHeader.getHeight()).setInterpolator(new AccelerateInterpolator(2));
  
          rltfullHeaderContainer.animate().translationY(-rltfullHeaderContainer.getTop()-rltTitleContainer.getTop()).setInterpolator(new AccelerateInterpolator(2)).start();
  
         listViewServices.animate().translationY(rltTitleContainer.getHeight()-listViewServices.getTop()).setInterpolator(new AccelerateInterpolator(2)).start();
  
        //listViewServices.setPadding((int)(d*14),(int)(d*2),(int)(d*14),(int)(d*3));
  
      }
  
      private void showViews()
      {
          controlsVisible=true;
  
          rltHeader.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2));
          rltfullHeaderContainer.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
         listViewServices.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
  
  
          //listViewServices.setPadding((int)(d*14),(int)(d*100),(int)(d*14),(int)(d*3));
  
      }
  </code></pre>