4

I'm trying to achieve the effect that the Google+ Android app has where there is a View that sits at the bottom of the screen, and when the user scrolls the ListView that sits behind it UP the View animates down, off screen. When the user scrolls the ListView down, even slightly, the View animates back up, on screen.

I've set up a GestureDetector, that is giving me callbacks for the scroll event on my ListView, and the callbacks are constant as I scroll so I know that part is working.

In my callback I'm trying to use the ViewPropertyAnimator to animate my y value as such:

headerView.animate().yBy(distanceY).start();

Nothing happens until I stop scrolling. Is there any way to throw this animation in with the ListView scroll on the UI thread? I get the feeling it's waiting.

Christopher Perry
  • 38,891
  • 43
  • 145
  • 187

1 Answers1

1

I've been fighting this one also. The trick I ended up using was to replace

headerView.animate().yBy(distanceY).start();

with

headerView.setTranslationY(floatValue);

Hope this helps!

DalvikDroid
  • 523
  • 6
  • 14
  • But it is not an animation. Do you have an answer why it behaves so, or how can I implement animation if I really want to? I have been struggling with same – Bully Maguire Jun 05 '20 at 07:24