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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:09:48+00:00 2026-05-27T13:09:48+00:00

I develop a widget based on ViewGroup and my problem is that I need

  • 0

I develop a widget based on ViewGroup and my problem is that I need to save position of items after the end of animation. I called setFillAfter(true) in my animation object I created AnimationListener and in it’s onAnimationEnd method call View.layout(l,t,r,b) to set the position after animation, because I want animation to start from new item’s position next time. But in this case it looks like items are layouted twice. If I don’t use View.layout(l,t,r,b) at the end of animation, next animation starts from previous position. Here is my code:

private void scrollUp() {
    for(int i = 0; i < getChildCount(); i++) {
        final View child = getChildAt(i);
        final int index = i; 
        final int newleft = child.getLeft() + mOffsetBetweenItems;
        final int newTop = child.getTop() - mOffsetBetweenItems;
        TranslateAnimation scrollUp = new TranslateAnimation(0, mOffsetBetweenItems, 0, -mOffsetBetweenItems);          
        scrollUp.setDuration(1500);
        scrollUp.setFillAfter(true);        
        scrollUp.setAnimationListener(
            new AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {}

                @Override
                public void onAnimationRepeat(Animation animation) {}

                @Override
                public void onAnimationEnd(Animation animation) {
                    child.layout(newleft, newTop, newleft + child.getMeasuredWidth(), newTop + child.getMeasuredHeight() );
                }
            }
        );

        child.startAnimation(scrollUp);
    }
}

Please give me an advice how should I reset view’s position accordingly to the end position of animation?

  • 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-27T13:09:48+00:00Added an answer on May 27, 2026 at 1:09 pm

    I did it. Here is the code:

    private void scrollUp() {
        for(int i = 0; i < getChildCount(); i++) {
            final View child = getChildAt(i);
            final int index = i; 
            final int newleft = child.getLeft() + mOffsetBetweenItems;
            final int newTop = child.getTop() - mOffsetBetweenItems;
            TranslateAnimation scrollUp = new TranslateAnimation(0, mOffsetBetweenItems, 0, -mOffsetBetweenItems);          
            scrollUp.setDuration(1500);
            scrollUp.setFillEnabled(true);        
            scrollUp.setAnimationListener(
                new AnimationListener() {
    
                    @Override
                    public void onAnimationStart(Animation animation) {}
    
                    @Override
                    public void onAnimationRepeat(Animation animation) {}
    
                    @Override
                    public void onAnimationEnd(Animation animation) {
                        child.layout(newleft, newTop, newleft + child.getMeasuredWidth(), newTop + child.getMeasuredHeight() );
                    }
                }
            );
    
            child.startAnimation(scrollUp);
        }
    }
    

    Just removed setFillAfter(true) and write setFillEnabled(true) instead of. But in this case I don’t understand the logic of setFillEnabled() working, because it provides behavior not like describes in documentation.

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

Sidebar

Related Questions

I need to develop an online service layer that will provide multi-role interactivity to
I'm about to develop widget that will consume a web service built on top
I develop and maintain a jQuery widget called jquery-ui-picklist . I've been wanting to
I have to develop a dashboard widget for Mac Osx to support 32/64 bit
I have a client who needs somebody to develop a countdown widget for their
We develop Win32 application that access to SQL 2005 database through Linq to SQL.
I'm trying to develop a widget for Android. I'm using Eclipse but I can't
I need to develop a Instant Lottery game app. I need an idea/procedure to
I want to develop an audio editor using Qt. For this, I need to
I'm trying to develop a widget with an EditText (only int allowed) and KeyEvent.

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.