了解android:duration和android:startDelay

gee*_*tha 5 android android-fragments

我正在运行片段的自动播放幻灯片放映。其中,每个片段都需要1.6秒才能完成滑动过程。另外,在上一个片段完成之前,应该开始下一张幻灯片。

含义片段开始滑动。完成过程需要1.6秒,但从片段A开始的时间起0.5秒后,片段B应该开始滑入。片段B的滑入过程也应该花费1.6秒。在fragmentB开始滑动0.5秒后,fragmentC应该开始。

我已经为每个片段创建了ObjectAnimator xml,如下所示,它们具有duration和startDelay属性。

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <objectAnimator
        android:interpolator="@android:anim/linear_interpolator"
        android:valueFrom="1"
        android:valueTo="0"
        android:valueType="floatType"
        android:propertyName="XFraction"
        android:duration="1600"
        android:startDelay="500"
         />
</set> 
Run Code Online (Sandbox Code Playgroud)

并设置android:duration =“ 1600”-表示每个片段都需要1.6秒才能滑入。我放android:startDelay =“ 500”表示下一个片段应在fragmentA的起始位置0.5秒后开始。这是正确的行为吗?我没有在幻灯片中看到正确的顺序。

The*_*oid 0

我过去用ObjectAnimator做了简单的动画。我的方法是全部编码,以便可以更改属性。我将给出一个代码示例。代码:

   ObjectAnimator animateObj;
   TextView animTextView;

   animateObj = ObjectAnimator.ofFloat(animTextView, "X", dest);
   animateObj.setDuration(5000);
   animateObj.start();
Run Code Online (Sandbox Code Playgroud)

玩得开心这个...