How to animate a FadeOut and FadeIn while textView changed text

£可爱£侵袭症+ 提交于 2019-12-06 07:35:52

TextSwitcher is exactly what you are looking for. Just use their setInAnimation() and setOutAnimation. Than the animations will run automatically if you change the text by setText()

By the look of your code you are telling the TextView to fade out after a change rather than fade in.

Also I'm not sure how effective this code will be as beforeTextChanged gets called only moments before the text is changed. There simply wont be enough time for any animation to happen on beforeTextChanged as it will be instantly replaced by your code in onTextChanged

Edit** Reply to comment below

So to get the textview to fade out then fade in with new content I would programmatically start a fadeOut animation rather than using a Textwatcher. I would give the fadeOut animation an AnimationListener and on animationEnd you can then set the new text before starting your fadeIn animation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!