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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:19:30+00:00 2026-06-13T10:19:30+00:00

I have a LinearLayout which I create in my xml file with its visibility

  • 0

I have a LinearLayout which I create in my xml file with its visibility set to Gone. I then showIt using an Animation and thats fine.

I fade out my LinearLayout using an AlphaAnimation and this works fine.

My Problem

The problem however is when I listen to the animation using an AnimationListener and the onAnimationEnd method is called, it doesn’t set the visibility of my LinearLayout to GONE as I can still click the ImageButtons that are inside it which is how I know they’re still there.

here is my xml with my LinearLayout.

<LinearLayout
        android:id="@+id/photoOptionBar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:alpha="1"
        android:background="@color/gpsBackground"
        android:orientation="horizontal"
        android:visibility="gone">

        <ImageButton
            android:id="@+id/displayShareBtn"
            style="@android:style/Widget.Holo.Button.Borderless.Small"
            android:background="@android:color/transparent"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:padding="20dp"
            android:src="@drawable/share"
            android:contentDescription="Share the picture"/>

        <ImageButton
            android:id="@+id/displayDiscardBtn"
            style="@android:style/Widget.Holo.Button.Borderless.Small"
            android:background="@android:color/transparent"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:padding="20dp"
            android:src="@drawable/contentdiscard"
            android:contentDescription="Discard Picture"/>

    </LinearLayout>

Here is my fade out method along with the listener.

AlphaAnimation alpha = new AlphaAnimation(1.0F, 0.0F);
    alpha.setDuration(PhotoDisplayFragment.FADE_DURATION); // Make animation instant
    alpha.setFillAfter(true); // Tell it to persist after the animation ends
    // And then on your layout
    final LinearLayout temp = this._photoOptionsBar;
    alpha.setAnimationListener(new AnimationListener() {

        @Override
        public void onAnimationEnd(Animation animation) {
            // TODO Auto-generated method stub
            temp.setVisibility(View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationStart(Animation animation) {
            // TODO Auto-generated method stub

        }

    });
    this._photoOptionsBar.startAnimation(alpha);

My Question

How do I set the visibility of the my LinearLayout to GONE after the animation ends?

Thanks in advance

  • 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-13T10:19:31+00:00Added an answer on June 13, 2026 at 10:19 am

    The issue is related to setFillAfter which let the animation persist when it is finished. Remove and all will work as expected. If if you need the fade in animatio check the _photoOptionsBar visibilty and if it is gone apply the inverse animation:

    new AlphaAnimation(0.0F, 1.0F);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the linearlayout which has the background set as rect.xml as mentioned below.
Just a straight forward problem. I have a LinearLayout which has attribute in xml
Say I have a LinearLayout with some elements in it as an .xml file.
I can't create layout in which I will have <LinearLayout> <TextView/> <ExpandableListView/> <Button/> </LinearLayout>
In my app which create an calendar using buttons..its working fine in all resolution
Context: I have a TableLayout (created using XML), which has one TableRow, which has
I have a layout defined in an XML file( base_layout.xml ) which may contain
I have a LinearLayout which holds a couple of buttons. To give the user
I have a simple vertical LinearLayout in which there is a button on the
I have write my own view Bar, which extends LinearLayout . My bar has

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.