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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:41:22+00:00 2026-05-24T16:41:22+00:00

I want to do a very simple alpha animation but I cannot find a

  • 0

I want to do a very simple alpha animation but I cannot find a valid way.

The idea is to perform this animation over a view:

  1. alpha from 0 to 1 of 1 second
  2. hold alpha at 1 for 5 seconds
  3. alpha from 1 to 0 of 1 second
  4. hold alpha at 0 for 5 seconds.
  5. start again on 1.

I’ve tried to implement that with an AnimationSet as:

AnimationSet animationSet = new AnimationSet(true);

Animation animation1 = new AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
animation1.setDuration(1000);

Animation animation2 = new AnimationUtils.loadAnimation(this, android.R.anim.fade_out);
animation2.setDuration(1000);
animation2.setStartOffset(5000);

Animation animation3 = new AlphaAnimation(0.0f, 0.0f);
animation3.setDuration(4000)
animation3.setStartOffset(6000);

animationSet.add(animation1);
animationSet.add(animation2);
animationSet.add(animation3);

etc..

but it seams that the third animation do a mess with all the alpha animations, I supose that this cause an internal incoherence in the way that Android manage this type of animation.

Any idea?

Thank you.

  • 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-24T16:41:23+00:00Added an answer on May 24, 2026 at 4:41 pm

    Ok Keep in mind these 2 points to solve this


    • If I want to animate 1.0f to 0.0f after 5 seconds with an animation duration of 1 seconds, this is ultimately a 1 second animation with a pause of 5 seconds.

      To acheive this:

      1. setDuration(1000) (it has a 1 second duration)
      2. setStartOffset(5000) (it will start after 5 seconds)

    • You only need 2 animations that will loop forever.

      1.0.0f to 1.0f with 5 seconds pause and 1 second duration

      2.1.0f to 0.0f with 5 seconds pause and 1 second duration


    And here is the code:

        animation1 = new AlphaAnimation(0.0f, 1.0f);
        animation1.setDuration(1000);
        animation1.setStartOffset(5000);
    
        animation2 = new AlphaAnimation(1.0f, 0.0f);
        animation2.setDuration(1000);
        animation2.setStartOffset(5000);
    
        textView.startAnimation(animation1);
    

    However to loop forever I will use AnimationListener because repeatCount is buggy:

        animation1 = new AlphaAnimation(0.0f, 1.0f);
        animation1.setDuration(1000);
        animation1.setStartOffset(5000);
    
        //animation1 AnimationListener
        animation1.setAnimationListener(new AnimationListener(){
    
            @Override
            public void onAnimationEnd(Animation arg0) {
                // start animation2 when animation1 ends (continue)
                textView.startAnimation(animation2);
            }
    
            @Override
            public void onAnimationRepeat(Animation arg0) {
                // TODO Auto-generated method stub
    
            }
    
            @Override
            public void onAnimationStart(Animation arg0) {
                // TODO Auto-generated method stub
    
            }
    
        });
    
        animation2 = new AlphaAnimation(1.0f, 0.0f);
        animation2.setDuration(1000);
        animation2.setStartOffset(5000);
    
        //animation2 AnimationListener
        animation2.setAnimationListener(new AnimationListener(){
    
            @Override
            public void onAnimationEnd(Animation arg0) {
                // start animation1 when animation2 ends (repeat)
                textView.startAnimation(animation1);
            }
    
            @Override
            public void onAnimationRepeat(Animation arg0) {
                // TODO Auto-generated method stub
    
            }
    
            @Override
            public void onAnimationStart(Animation arg0) {
                // TODO Auto-generated method stub
    
            }
    
        });
    
        textView.startAnimation(animation1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I want to do is very simple but I'm trying to find the
I'm sure what I want is very simple but I cannot figure out how.
I'm creating a very simple django upload application but I want to make it
I just want to design this very simple website. Basically there are multiple pages
I want to write very simple C++ programs on my Mac but I get
I want to do very simple thing, but I'm not success. I have button
I have a very simple Country entity which I want to cache. This works
I want to create a very simple range picker, but I'm having 3 problems
I want to create a very simple HTML/AJAX based GUI for a Python program.
I want to develop a very simple 2D game in Python. Pygame is the

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.