I am trying to play a set of animations sequentially using the Animator
set. Everything is working except for the alpha animation(set1
). It is changing from 0.25f to 1 but it is not fading throughout the animation and at the end of the set1
animation it is changing from 0.25 to 1 and not taking in consideration the setDuration
(as a result I am not getting the fade in effect). So I don't have the fade in effect... When I do this animation by itself the fade in effect is there....Any ideas?
I am using the wonderful nineoldandroids library to implement this.
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageView image = (ImageView) findViewById(R.id.image); final AnimatorSet set = new AnimatorSet(); set.play(ObjectAnimator.ofFloat(image, "translationX", 0, 100).setDuration(3000)); final AnimatorSet set1 = new AnimatorSet(); //THIS IS THE PROBLEMATIC ANIMATION!! set1.play(ObjectAnimator.ofFloat(image, "alpha", 0.25f, 1).setDuration(3000)); final AnimatorSet set2 = new AnimatorSet(); set2.play(ObjectAnimator.ofFloat(image, "translationX", 100, 200).setDuration(3000)); final AnimatorSet set3 = new AnimatorSet(); set3.playSequentially(set,set1,set2); set3.start(); }
android.animation.ObjectAnimator. This subclass of ValueAnimator provides support for animating properties on target objects. The constructors of this class take parameters to define the target object that will be animated as well as the name of the property that will be animated.
ObjectAnimator is a Subclass of ValueAnimator, which allows us to set a target object and object property to animate. It is an easy way to change the properties of a view with a specified duration. We can provide the end position and duration of the animation.
While working on 4.0+
ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(image, View.ALPHA, 0,1);
try this.
ObjectAnimator.ofFloat(image, "alpha", 0.25f, 1, 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With