after I load an animation from res/anim I need to only change the startOffset of it.
programmatically, it doesn't work. but from xml it's ok.
@JvmStatic
@BindingAdapter("animation", "animationDelay", requireAll = false)
fun setAnimation(view: View, animId: Int, delay: Long?) {
AnimationUtils.loadAnimation(view.context, animId).apply {
if (delay != null) startOffset = delay // doesn't work
view.startAnimation(this)
}
}
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
android:startOffset="2000"> <!-- works -->
<translate
android:duration="1500"
android:fromYDelta="100%"
android:toYDelta="0" />
<alpha
android:duration="1000"
android:fromAlpha="0"
android:startOffset="500"
android:toAlpha="1" />
</set>
so how should I achieve this? or should I create a separate animation file for each of delay values?