I've used ObjectAnimator.ofFloat in an Android App wich doesn't work on every Device the same way.
MainActivity (extends Activity):
Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startAnimation();
}
});
public void startAnimation() {
ImageView aniView = (ImageView) findViewById(R.id.imageView1);
ObjectAnimator fadeOut = ObjectAnimator.ofFloat(aniView, "alpha", 0f);
fadeOut.setDuration(2000);
ObjectAnimator mover = ObjectAnimator.ofFloat(aniView, "translationX", -500f, 0f);
mover.setInterpolator(new TimeInterpolator() {
@Override
public float getInterpolation(float input) {
Log.v("MainActivity", "getInterpolation() " + String.format("%.4f", input));
return input;
}
});
mover.setDuration(2000);
ObjectAnimator fadeIn = ObjectAnimator.ofFloat(aniView, "alpha", 0f, 1f);
fadeIn.setDuration(2000);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(mover).with(fadeIn).after(fadeOut);
animatorSet.start();
}
Samsung Galaxy S4 (Android 4.4.2):
getInterpolation() 1,0000
getInterpolation() 1,0000
Samsung Galaxy S5 (Android 4.4.2):
getInterpolation() 0,0000
getInterpolation() 0,0000
getInterpolation() 0,0085
getInterpolation() 0,0170
getInterpolation() 0,0255
...
...
getInterpolation() 0,9740
getInterpolation() 0,9825
getInterpolation() 0,9910
getInterpolation() 0,9995
getInterpolation() 1,0000
Has anyone an Idea, why this doesn't work properly?