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

  • Home
  • SEARCH
  • 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 4272980
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:39:04+00:00 2026-05-21T07:39:04+00:00

I am having following layout <merge> <LinearLayout android:id=@+id/ll_main android:layout_height=fill_parent android:layout_width=fill_parent /> <LinearLayout android:id=@+id/ll_sub android:layout_height=fill_parent

  • 0

I am having following layout

<merge>
    <LinearLayout
        android:id="@+id/ll_main"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        />
    <LinearLayout
        android:id="@+id/ll_sub"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        />  
</merge>

What I want to do is to show/hide the ll_sub layout on runtime through setVisibility() but it is not working.

When I am setting android:visibility="gone" (also I had checked with invisible) from the xml of ll_sub then it is not displayed on the screen and this time when I use setVisibility() to show this layout on runtime, it is displayed but when I try to hide this layout once it is displayed then it is not hiding.

EDIT

I am trying to show/hide this linear layout on click of a button.

LinearLayout ll;
Button minimize;
int visibility=0;

@Override
public void onCreate(Bundle savedInstanceState)
{
    ll=(LinearLayout)findViewById(R.id.ll_sub);
    minimize=(Button)findViewById(R.id.minimize);
    minimize.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View view)
        {

            if(visibility==0)
            {
                visibility=2;
            }
            else
            {
                visibility=0;
            }
            ll.setVisibility(visibility);

        }
    });
}
  • 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-21T07:39:05+00:00Added an answer on May 21, 2026 at 7:39 am

    It looks like you’re setting the wrong constants for changing view visibility.

    GONE == 8
    INVISIBLE == 4
    VISIBLE == 0
    

    However, you should never rely on the actual values that Android happened to designate to represent their constants. Instead use the the values defined in the View class: View.VISIBLE, View.INVISIBLE, and View.GONE.

    // snip...
    if(visibility == View.VISIBLE)
    {
        visibility = View.GONE;
    }
    else
    {
        visibility = View.VISIBLE;
    }
    ll.setVisibility(visibility);
    

    And don’t forget to call invalidate() on the view 🙂

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

Sidebar

Related Questions

i am having the following layout file <ImageView android:id=@+id/imageView1 android:layout_width=wrap_content android:layout_height=wrap_content android:src=@drawable/no_image /> <LinearLayout
I have the following layout for my ImageView : <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android
I'm having difficulty getting the GUI layout results I want in an Android app.
i m having following type of simple sql server table Here I want to
I have the following layout for a dialog: <?xml version=1.0 encoding=utf-8?> <TableLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/categorylist
I'm having the following issue developing in android 2.2 (API 8): I have a
I'm having trouble getting the following three-column layout to work: A B C +-------+-------------------+------------+
I'm having trouble finding the right solution for this fully fluid layout. I want
Using JqueryMobile, I wish to achieve the following layout: Having nice decorations boxes to
I'm trying to obtain the following layout in android: http://i54.tinypic.com/iz8enk.png Where in the white

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.