According to documentation setStartTime should help with starting animation from particular step. What I mean is if I have animation android:duration = "2000" I want to make it start in java from particular time e.g from 1500 or whatever else. Once again it is not delay of animation start like setStartOffset but start from particular step of animation.
After digging a little bit more I have found that startAnimation is not affected by startTime and always begins from the 1st frame. On the other hand setAnimation should be used for setStartTime unfortunately I can not pass there my long value and can not pass it into currentAnimationTimeMillis.
updated code
in MainActivity ...
Animation introani;
TextView intro;
in onCreate..
intro= (TextView) findViewById(R.id.intro);
introani = AnimationUtils.loadAnimation(this, R.anim.introalpha);
ViewTreeObserver vto = intro.getViewTreeObserver(); //@diegoveloper
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
introani.setStartTime(1500);
intro.setAnimation(introani);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
intro.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
intro.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
It still has duration of 2000 but in that case animation never starts.
Any ideas how to run animation from particular step?