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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:50:20+00:00 2026-06-17T07:50:20+00:00

I have a linearLayout that disappears when I hit a button, it comes back

  • 0

I have a linearLayout that disappears when I hit a button, it comes back when I press the button again. But it does it so fast, it doesn’t look nice.
I do this via:

disappearView.setVisibility(View.GONE);

I would like to add some animation… If I just set visibity to invisible the space where the layout was is still there. So I tried this:

if (disappearView.getVisibility() == View.VISIBLE){
            Animation out = AnimationUtils.makeOutAnimation(this, true);
            disappearView.startAnimation(out);
            disappearView.setVisibility(View.INVISIBLE);
            disappearView.setVisibility(View.GONE);

        }
        else {
            Animation in = AnimationUtils.loadAnimation(this, android.R.anim.fade_in);
            disappearView.startAnimation(in);
            disappearView.setVisibility(View.VISIBLE);      
        }

This does the animation too fast and disappears. You can’t see it at all. Do I need to use a thread to start gone after invisible is set…or a delay? Or is there a better way of doing all this?

  • 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-17T07:50:21+00:00Added an answer on June 17, 2026 at 7:50 am

    I’m not sure exactly what you’re trying to accomplish…do you want the LinearLayout to fade out over a little bit of time rather than instantly disappear? And then once it fades out be removed from the parent via View.GONE?

    If so, you can use an AlphaAnimation for the fade out and then attach a listener like EvZ posted:

    AlphaAnimation fadeOutAnimation = new AlphaAnimation(1, 0); // start alpha, end alpha
    fadeOutAnimation.setDuration(1000); // time for animation in milliseconds
    fadeOutAnimation.setFillAfter(true); // make the transformation persist
    fadeOutAnimation.setAnimationListener(new AnimationListener() {         
        @Override
        public void onAnimationEnd(Animation animation) {
            linearLayout.setVisibility(View.GONE);
        }
    
        @Override
        public void onAnimationRepeat(Animation animation) { }
    
        @Override
        public void onAnimationStart(Animation animation) { }
    });
    
    linearLayout.setAnimation(fadeOutAnimation);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a LinearLayout that I've styled to look like a button , and
I have a LinearLayout that will have a cancel button and a progress bar,
I have this simple LinearLayout that shows up fine in Graphical Layout but when
I have a code that should get a LinearLayout (with more LinearLayout's inside), and
There is one image on LinearLayout. I have to move that image in any
I have a Linear Layout that has a Button and a TextView on it.
I have a LinearLayout and its child - ImageView. My activity's onCreate does nothing
I have a LinearLayout that I would like to change the background color of
I have a View that inherits from LinearLayout that inflates itself. After it has
I want to add a webview to my layout.But that layout have few other

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.