Java – Animation on Android

Animation on Android… here is a solution to the problem.

Animation on Android

I’ve been looking around for answers and really trying to dive into Android programming before asking any questions. I know this site is here to help, but it’s not a redundant and lazy way out either. Although I am a beginner to android, I need some help if some of you have time. I looked at a question that I really thought would help (URL: Button animations in android ), but it ended up causing my program to crash. I also looked at this http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-a-simple-property-animation/, that didn’t really get me to the right answer I was looking for either. Unfortunately, now I don’t have the code, but I’m trying to copy the code from these two sample sites I provided. When I declare the animated objects in the actual Java code, they all crash
Namely

    ImageView confettiStart = (ImageView) findViewById(R.id.confetti);
    AnimatorSet confettiSet =(AnimatorSet)AnimatorInflater.loadAnimator(this,R.animator.startconfettianimations);

My goal is basically to get confetti animations to appear from the top of my screen and scroll down to the bottom of my screen. To create the “animation”, I created about 8 different images, but I don’t really know how to implement it in Android itself. I would appreciate it if someone could help or point in the right direction. Thank you so much.

Solution

Use objectAnimator for the View and leave the x parameter unchanged while changing the y parameter to a value from 0 to 600 or the same. Hope it works. Or the translation animator will do this trick, trying to keep x1=0 x2=0 and y1=0 y2=600.

Related Problems and Solutions