【问题标题】:Add delay between fragment transactions在片段事务之间添加延迟
【发布时间】:2017-11-11 16:56:28
【问题描述】:

我的应用上有一个主屏幕,我在此屏幕的开头以编程方式添加了几个具有不同内容的片段。我正在尝试为每个片段的外观设置动画,我希望它们一个接一个地显示,但无法弄清楚,它们都同时出现。

我最好的猜测是使用具有不同 startOffset 的不同动画文件

动画_1.xml

<?xml version="1.0" encoding="utf-8"?>
<scale  xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fromXScale="0.0"
    android:toXScale="1.0"
    android:fromYScale="0.0"
    android:toYScale="1.0"
    android:duration="500"
    android:pivotX = "50%"
    android:pivotY = "50%" />

动画_2.xml

<?xml version="1.0" encoding="utf-8"?>
<scale  xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:fromXScale="0.0"
    android:toXScale="1.0"
    android:fromYScale="0.0"
    android:toYScale="1.0"
    android:duration="500"
    android:startOffset="500"
    android:pivotX = "50%"
    android:pivotY = "50%" />

但我要添加大约 10 个不同的片段,我认为这不是最有效的方法。 ¿ 有什么想法吗?

【问题讨论】:

  • 在另一个帖子 [1] 中查看此 [链接][1]:stackoverflow.com/questions/4932462/…
  • 谢谢,但我已经知道如何制作动画了。我想要完成的是使用相同的动画,并在不同的时间一个接一个地显示不同的片段。

标签: android android-fragments android-animation


【解决方案1】:

将此添加到您的第二个片段动画中

android:startOffset = "x"

x 将是您第一个片段的动画时间

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-10
    • 2016-03-03
    • 2021-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多