Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9232953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:26:09+00:00 2026-06-18T06:26:09+00:00

I have a circle that I want to bounce, so it would expand in

  • 0

I have a circle that I want to bounce, so it would expand in width, and collapse in height, then the reverse and the same for a few times. That all works with a few ScaleAnimations in a row. The problem is, that I want pivotY to be the bottom of the view. In this case every time a new animation starts it’ll reset the pivot point to the center. Here’s my code:

    bounceAnimationPartOne = new ScaleAnimation(1.0f, 1.0f, 1.62f, 0.62f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
    bounceAnimationPartOne.setDuration(45);
    bounceAnimationPartOne.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.startAnimation(bounceAnimationPartTwo);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    bounceAnimationPartTwo = new ScaleAnimation(1.62f, 0.62f, 0.76f, 1.3f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
    bounceAnimationPartTwo.setDuration(90);
    bounceAnimationPartTwo.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.startAnimation(bounceAnimationPartThree);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    bounceAnimationPartThree = new ScaleAnimation(0.76f, 1.3f, 1.23f, 0.81f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
    bounceAnimationPartThree.setDuration(105);
    bounceAnimationPartThree.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.startAnimation(bounceAnimationPartFour);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    bounceAnimationPartFour = new ScaleAnimation(1.23f, 0.81f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 1.0f);
    bounceAnimationPartFour.setDuration(60);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:26:11+00:00Added an answer on June 18, 2026 at 6:26 am

    I ended up writing my own custom Animation that basically does 4 scale animations in a row:

    public class BounceAnimation extends Animation {
        private final List<Float> expansionValuesX;
        private final List<Float> expansionValuesY;
        private final List<Float> timing;
    
        private int currentTimingIndex;
        private float currentTimingSum;
    
        private float pivotX;
        private float pivotY;
    
        public BounceAnimation(List<Float> expansionValuesX, List<Float> expansionValuesY, List<Float> timing, int duration) {
            this.expansionValuesX = expansionValuesX;
            this.expansionValuesY = expansionValuesY;
            this.timing = timing;
    
            setDuration(duration);
        }
    
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            float sx = 1.0f;
            float sy = 1.0f;
    
            if (currentTimingIndex < timing.size() - 1 && interpolatedTime >= currentTimingSum + timing.get(currentTimingIndex)) {
                currentTimingSum += timing.get(currentTimingIndex);
                currentTimingIndex++;
            }
    
            float currentFromX = expansionValuesX.get(currentTimingIndex);
            float currentFromY = expansionValuesY.get(currentTimingIndex);
            float currentToX = expansionValuesX.get(currentTimingIndex + 1);
            float currentToY = expansionValuesY.get(currentTimingIndex + 1);
    
            float currentInterpolatedTime = (interpolatedTime - currentTimingSum) / timing.get(currentTimingIndex);
    
            if (currentFromX != 1.0f || currentToX != 1.0f) {
                sx = currentFromX + ((currentToX - currentFromX) * currentInterpolatedTime);
            }
            if (currentFromY != 1.0f || currentToY != 1.0f) {
                sy = currentFromY + ((currentToY - currentFromY) * currentInterpolatedTime);
            }
    
            if (pivotX == 0 && pivotY == 0) {
                t.getMatrix().setScale(sx, sy);
            } else {
                t.getMatrix().setScale(sx, sy, pivotX, pivotY);
            }
        }
    
        @Override
        public void initialize(int width, int height, int parentWidth, int parentHeight) {
            super.initialize(width, height, parentWidth, parentHeight);
    
            pivotX = resolveSize(Animation.RELATIVE_TO_SELF, 0.5f, width, parentWidth);
            pivotY = resolveSize(Animation.RELATIVE_TO_SELF, 1.0f, height, parentHeight);
    
            currentTimingIndex = 0;
            currentTimingSum = 0;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm drawing circle and want that when lines match together then generate error.I have
I have an Image (which looks like a round loading circle) that I want
I have a div that I want to display as a small colored circle.
I have a ball (a dynamic body in the shape of a circle) that
I have this CSS3 animation that works in Chrome .circle-label-rotate { -webkit-animation-name: rotateThis; -webkit-animation-duration:.5s;
i have drawed some figure(circle, rectangle or just a line) and after that i
In Python, say I have some class, Circle, that inherits from Shape. Shape needs
I have a series of shapes that I want the user to be able
I want to create a circle that is sectioned into 4 quarters, and each
I basically have a simple problem in my program that I just want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.