【问题标题】:setVisibility not work after animation set for a view为视图设置动画后 setVisibility 不起作用
【发布时间】:2023-03-28 22:55:01
【问题描述】:

搜索了一些这样的问题后,我仍然不知道它的细节。有人说在设置可见性之前调用clearAnimation 可以正常工作,但对我来说,有时它不起作用。那么,有没有人知道它为什么有效或为什么无效?

谢谢!!

【问题讨论】:

  • 你能贴一些代码吗?
  • 抱歉,我现在无法获取我的源代码。你用过github开源项目“AndroidViewAnimations”做动画吗?我无法为使用 YoYo 动画的视图设置可见性(GONE)。我将在明天发布我的源代码。
  • YoYo.with(Techniques.Pulse).duration(10000).playOn(aq.id(R.id.splash).getView());我用这样的东西作为视图。

标签: android animation visibility


【解决方案1】:

试试这个

animation.setAnimationListener(new Animation.AnimationListener() {

    @Override
    public void onAnimationStart(Animation animation) {}

    @Override
    public void onAnimationEnd(Animation animation) {
    view.clearAnimation();
    view.setVisibility(View.GONE);
    }

    @Override
    public void onAnimationRepeat(Animation animation) {}
});

【讨论】:

  • 根据 StackOverflow 规则,您应该清楚地解释为什么您的解决方案有效。请不要忘记下次这样做。
猜你喜欢
  • 2012-01-31
  • 2017-05-19
  • 2017-04-14
  • 2013-04-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多