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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:17:49+00:00 2026-05-31T18:17:49+00:00

I am adding the animation to the imageview and I would like that to

  • 0

I am adding the animation to the imageview and I would like that to stay in that animated state till the time button is pressed on button press move it to the previous state
here is my code, using setFillAfter don’t let it to restore and setting it to false it don’t stay in the animated state

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        i=(ImageView)findViewById(R.id.imageView1);
        d=(Button)findViewById(R.id.button1);
        a=new AnimationSet(false);
        ScaleAnimation s=new ScaleAnimation(0, 2, 0, 2);
        TranslateAnimation t=new TranslateAnimation(0, 100, 0, 0);

        a.addAnimation(s);
        a.addAnimation(t);
        a.setRepeatCount(0); 
        a.setDuration(500);     
        a.setFillAfter(false);

        a.setInterpolator(new AccelerateDecelerateInterpolator()); i.clearAnimation();

        d.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

            i.clearAnimation();
            }
        });

        i.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub

                i.startAnimation(a);
                System.out.println("OnTouch called>>>>>>>>>>>");
                return false;
            }
        });
    }
  • 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-31T18:17:50+00:00Added an answer on May 31, 2026 at 6:17 pm

    Change Repeat Mode to Infinite

    a.setRepeatMode(Animation.INFINITE);
    

    and use Animation Listener so now you can start Animation and stop Animation when ever you want.For More Details. See This Details example

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

Sidebar

Related Questions

I have what I thought was a relatively easy Ajax/animation that I'm adding to
I want to have a 2 second animation of an ImageView that spends 1000ms
I am adding a button to a UIView and creating an animation. How do
Adding the row one by one in the button click.. (i tried but its
I want to make an animation, like the deleting a note in iPhone Notes
NavigationControllers have ViewController stacks to manage, and limited animation transitions. Adding a view controller
I have about 100 elements in like and am trying to create an animation
I am trying to achieve adding the animated gifs into my application. 1- I
Update: There is no problem here. Turns out I was re-adding the animation every
I'm adding an ImageView dynamically to my layout and then I want it 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.