Android showing keyboard cancels animation

2019-05-20 16:49发布

问题:

In my app a user can animate a view (fragment) on another view. A simple ObjectAnimator does its tranlateY trick and after the animation is complete the view is visible with TextViews and EditTexts.

But when pressing an EditText the keyboard shows and for some reason my view, which was animated with ObjectAnimator, returns to its pre animated position. First I thought it was because the view gets redrawn (like orientation change) so I added "setRetainInstance(true);" but that doesn't work either.

How can I fix this problem?

回答1:

Can you essentially reverse the way the animation is done. Instead of initializing the graphic at it's starting location and having it move to a final location. Have it initialize at the the final location and then have the animation key frame it from the beginning to the end. I think this would be a better solution because I don't think that the Animation actually changes the layout but simply animates it.

Hope this helps!