Sample Animator Code Not Working f..
In Android development, sometimes you want to animate some views or objects by modifying and adjusting their property values. You can also improve your animation using various kinds of interpolators (or create your own interpolator).
Difficulty in managing animations / animators codes in Android
Codes for animation often tends to not that tolerantly easy; sometimes you need to declare variable Animator and/or Animation and/or AnimatorSet, and more.. and if you want to add something to do specifically when the animation starts / ends / or is happening, you need to add or set listeners to it and you will have callbacks returned on that timing and then do write codes inside callback method and… yucks.
Compared to that, I personally feel writing all of the animation / animator codes on xml file is slightly less stressful although at first I really feel those
By writing all of the animation / animator codes on XML, all you need to do in your program codes is simply loading those xml files and do start animations / animators declared on that xml file.. I firstly thought so.
And sample not working..
So I tried the basic sample code from Android Developer site that introduces PropertyAnimation with animators declared on xml file, which is the codes below:
<set android:ordering="sequentially"> <set> <objectAnimator android:propertyName="x" android:duration="500" android:valueTo="400" android:valueType="intType"/> <objectAnimator android:propertyName="y" android:duration="500" android:valueTo="300" android:valueType="intType"/> </set> <objectAnimator android:propertyName="alpha" android:duration="500" android:valueTo="1f"/> </set>
And Java codes:
AnimatorSet set = (AnimatorSet) AnimatorInflater.loadAnimator(myContext, R.anim.property_animator); set.setTarget(myObject); set.start();
And it does not work. f..
I will update this post when I realize or know something, things that I may have done wrong or anything else.
So as I could not figure out why this is not working by self, I have posted the question on stackoverflow.