For my current project I'm building a pulldown view with a handle and a content. When I move the handle by dragging it everything is fine. Then I let it go and start an animation to fully open or close the pulldown.
First: without the animation in it everything is fine, but off course not that smooth...
So I've added this for the animation:
ObjectAnimator animHandle = ObjectAnimator.ofFloat(mHandleContainer, "y", newHandlePosition);
ObjectAnimator animContent = ObjectAnimator.ofFloat(mContent, "y", newContentPosition);
final AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animHandle, animContent);
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
animatorSet.setDuration(MAX_ANIMATION_DURATION);
animatorSet.start();
Everything is just fine utill here.
But then, when I press the handle (mHandleContainer) again, I want to know where the handle is positioned so I do a
mHandleContainer.getTop()
And that is where it all goes wrong. When I initialize the custom component I set the top of the handle to 0. So far so good, then I start dragging, when I let go I see that I will animate to a position of 1134 pixels. Which is fine (meaning the pull down will be entirely open).
But then I press the handle again and get the top (getTop()) and it still returns me 0.
What I want is that my view's getTop() function returns me 1134 again.
Is that possible?
Or should I do something in the onAnimationEnd method of my AnimatorListener? I already tried to do a mHandleContainer.layout(..) in there and then my getTop() is ok, but then my layout is screwed...
And tricks here for letting the animation end on the correct position (as it does) and persist the position in the view?
I already had a look on SO (and Google) but didn't find something useful. The only thing close to my problem that I could find was this: NineOldAndroids, not clickable view after rotation or move But didn't help either...