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 4620172
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:31:28+00:00 2026-05-22T02:31:28+00:00

I am trying to animate cards across the screen. My code looks like this:

  • 0

I am trying to animate cards across the screen.

My code looks like this:

private void animate(ImageView  animationSource, ImageView  animationTarget, int animationDuration, int animationDelay) {
    int[] animationSourcePosition = {0,0};
    int[] animationTargetPosition = {0,0};

    animationSource.getLocationInWindow(animationSourcePosition);
    animationTarget.getLocationInWindow(animationTargetPosition);

    TranslateAnimation cardDealingAnimation = new TranslateAnimation(
        Animation.ABSOLUTE,animationSourcePosition[0],
        Animation.ABSOLUTE,animationTargetPosition[0],
        Animation.ABSOLUTE,animationSourcePosition[1],
        Animation.ABSOLUTE,animationTargetPosition[1]);

    cardDealingAnimation.setDuration(animationDuration);
    cardDealingAnimation.setStartOffset(animationDelay);
    animationTarget.startAnimation(cardDealingAnimation);
}

What happens is that it just pops up in the new place without showing the places in-between.
Funnily enough, on one of my targets it does sometimes show up.

  • 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-05-22T02:31:29+00:00Added an answer on May 22, 2026 at 2:31 am

    There are two problems I see here.

    One problem is that you’re getting the position of your objects in the Window, where you should just use the position of the objects in their parent container. It’s easier, faster, and more what you’re looking for – where the objects live in their layout. If they do not live in the same container, then you may need to get the position in the window or the screen, and then just deal with delta values (the difference in their locations, not the absolute locations themselves).

    You can get these simple container positions from the getLeft() and getTop() methods on View.

    The second problem is that the TranslateAnimation parameters don’t do what you think they do. The numeric values (the second, fourth, sixth, and eighth values) specify the starting and ending locations of the target object as offsets from its current location. That’s why they have the word ‘delta’ in them in the method declaration. So you should not send in the absolute coordinates of the object positions their, but, rather, the deltas that they should have.

    Let’s suppose you have calculated an xDelta and yDelta as the difference in x and y between the source and target positions. If you’re animating the source to the target position, then you would use something like 0, xDelta, 0, yDelta for these values.

    Note that TranslateAnimation() does not physically move the object – it just draws it in a different place. So as soon as the animation is complete, the object will snap back to its original location. You may want to set the fillAfter property to maintain its end location on the screen when the animation completes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to animate a label across the screen however I cannot seem
i'm trying to animate an object in several steps across the screen until it
I'm trying to animate two images moving across the screen using Monotouch. I've been
I am trying to animate a UIView here. It looks like a rectangle, and
I'm trying to animate a private variable named radius, which works. However while its
I'm trying to animate a simple ImageView in my application and I want it
I'm trying to animate a waterfall of divs like in duitang.com . i tried
This is my code, i'm trying to drag and drop a card which will
I am trying to animate an image using following code: [UIView beginAnimations:nil context:NULL]; [UIView
I'm trying to animate a UIWebview being removed from the screen. I'm using an

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.