title: Android : hide/show footer/header as scrolling scrollview down/up
body: <p>I am trying to implement a way to have my <strong>footer slide away down</strong> and my  <strong>header to slide away up</strong> while user scrolls down the scrollview.</p>
  
  <p>And vice-versa, as the user scrolls up the scollview, I want my footer to slide in from the bottom and the header slide in form the top.</p>
  
  <p>Regarding the animation, I have found this good library <a href="https://github.com/daimajia/AndroidViewAnimations" rel="nofollow noreferrer">https://github.com/daimajia/AndroidViewAnimations</a> that comes with a lot of nice animations.</p>
  
  <p>The closest example for what I am looking for, is the default Android Twitter application that makes it's footer disappear as the user scrolls his timeline down and makes it reappear as the user scrolls up.</p>
  
  <p>By header, I am not talking about the Android Toolbar (op AppBar or whatever). It's a customed-made UI element that I want to animate while the user scrolls.</p>
  
  <p>Same thing goes for the footer : it's a customed-made UI element.</p>
  
  <p>While looking for solutions, I stumble upon this answer <a href="https://stackoverflow.com/a/28712465/3535408">https://stackoverflow.com/a/28712465/3535408</a> but it does not work.
  Indeed, placing a <code>Log.d</code> inside the <code>if</code>and <code>else if</code> shows that a simple touch with my finger triggers both a <code>MotionEvent.ACTION_DOWN</code> and a <code>MotionEvent.ACTION_UP</code> event. The same applies as I am sliding my finger up/down making the scrollview scrolls up/down : both events are triggered at the end when I stop touching the scrollview.</p>
  
  <p>Is there a way to improve this solution ? Because as of now, as <strong>both <code>MotionEvents</code></strong> are triggered, <strong>both animations</strong> are also triggered so the result is quite horrible.</p>
  
  <p>Thanks !</p>