【问题标题】:Android Animation stops working after being repeatedAndroid动画重复后停止工作
【发布时间】:2016-03-29 15:28:12
【问题描述】:

我在 android 中有一个视图幻灯片,它有一个过渡幻灯片,幻灯片可以完美运行一段时间,然后动画停止工作,视图只是出现而没有幻灯片。 这是我正在使用的代码示例,处理程序每​​ 10 秒重复一次

`

TranslateAnimation slideIn = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_SELF,1f,TranslateAnimation.RELATIVE_TO_SELF ,0f,TranslateAnimation.RELATIVE_TO_SELF, 0f, TranslateAnimation.RELATIVE_TO_SELF,0f);
 slideIn.setDuration(250);
 slideIn.setFillAfter(true);
  container.startAnimation(slideIn);

`

container 是一个具有更新视图的 RelativeLayout,每 10 秒我更新容器视图并调用 SlideIn 动画

知道为什么动画停止工作了吗?

【问题讨论】:

    标签: android android-layout android-animation android-view translate-animation


    【解决方案1】:

    删除处理程序并在添加这些行后尝试 -

        slideIn.setRepeatCount(10);
        slideIn.setRepeatMode(Animation.RESTART);
    

    【讨论】:

    • 无法删除处理程序,因为我需要更改视图的内容
    猜你喜欢
    • 1970-01-01
    • 2012-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多