search

Home  >  Q&A  >  body text

android ViewAnimation执行完无法隐藏控件?

项目里给一个TextView设置放大和平移的动画,执行完以后,设置了View.GONE。发现布局中还是能看到。getVisibility()返回的是8,不可见。这是什么原因呢。

原因:设置了setFillAfter(true);,具体为什么不知道。
解决办法:

tv.clearAniamtion();
tv.invalidate();
     
     

参考:http://blog.csdn.net/nijiayy/article/details/40683639

黄舟黄舟2799 days ago770

reply all(4)I'll reply

  • 天蓬老师

    天蓬老师2017-04-17 15:23:39

    Reason: setFillAfter(true); is set, I don’t know the specific reason.
    Solution:

    tv.clearAniamtion();
    tv.invalidate();
     
     

    Reference: http://blog.csdn.net/nijiayy/article/details/40683639

    reply
    0
  • 黄舟

    黄舟2017-04-17 15:23:39

    If you have code when you ask a question, it is best to post the main code
    This way others can better handle your problem

    reply
    0
  • 阿神

    阿神2017-04-17 15:23:39

    Is the moving position wrong?

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 15:23:39

    ViewAnimation essentially does not change the properties of the control. You can follow the method you mentioned, clear and then invalidate after the animation ends; you can also use propertyAnimation directly to implement animation.

    reply
    0
  • Cancelreply