Android TranslateAnimation on button flickers

2019-06-18 12:42发布

If you perform a TranslateAnimation on a button then only the drawing moves but not the real button, so you have to move the button yourself with an animationlistener.

Now you know what I already know and did and this works.

The problem lies in what the user sees. After the animation (so when I move the button) you see a short flickering in the screen. This is due to the drawing already being up, then I change the margin of the button so the drawing moves up even more, before it comes crashing down because of the fillAfter which is set to false

Any ideas on how to fix this? It may also be a whole other approach (without a translate-animation for example) but the effect needs to be the same (without the flicker ofcourse ;) )

1条回答
叛逆
2楼-- · 2019-06-18 13:28

There is piece of text of answer to my own question when faced the same problem

"After placing the view to new position at the end of animation by using above method. And here still comes another problem of blinking which is due to the problem in android animation listener method which is that it gets called before actually animation ends and causes blinking effect, a tricky solution to it is by putting following line of code at first line of public void onAnimationEnd(Animation a) method"

// in my case animation applied to notes_editor so the code will be 
  notes_editor.clearAnimation();

for complete answer here is link

EditText stucks after animation and alive back on scrolling......?

查看更多
登录 后发表回答