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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:35:47+00:00 2026-05-24T05:35:47+00:00

What is the best way to hide layout on button press,i.e, hide a linear

  • 0

What is the best way to hide layout on button press,i.e, hide a linear layout where main.xml contains many linear layouts or is it to be done by some other layout please let me know
Below i have given an example of two linear layouts my question is
1.IS it correct
2on browse button press show linear layout2 ,hide linear layout1 and on send button press show linear layout1, hide linear layout2

Show me the relevant code to achieve this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="vertical" android:id="@+id/linearLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content">
 <Button android:text="Browse" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

</LinearLayout>
<LinearLayout android:id="@+id/linearLayout2" android:layout_width="wrap_content" android:layout_height="wrap_content">

  <Button android:text="Send" android:id="@+id/send" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>

</LinearLayout>
  • 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-24T05:35:47+00:00Added an answer on May 24, 2026 at 5:35 am
    LinearLayout llToHide = (LinearLayout)findViewById(R.id.linearLayout1);
    llToHide.setVisibility(View.INVISIBLE);
    

    To show it again call:

    llToHide.setVisibility(View.VISIBLE);
    

    To make it as if it’s not there call:

    llToHide.setVisibility(View.GONE);
    

    The xml attribute to make a View visible, invisible, or gone is:

    android:visibility="visible"
    android:visibility="invisible"
    android:visibility="gone"
    

    The difference between “invisible” and “gone” is that “invisible” will not be shown but the rest of the layout will stretch or move as if it is there. A view with a “gone” attribute will act as if it doesn’t exist, but you can still change/manipulate it in case you want it seen eventually.

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

Sidebar

Related Questions

What is the best way to hide Tab headers when there is only a
Bascially I want to know the best way to hide/show an ASP.NET control from
What is the best way to hide inline Javascript and CSS from downlevel browsers?
I just realized that there is no best way to hide MySQL string connection
What is the best way to create a hide and show effect in rails
What's the best way to go about creating a play/pause button in Qt? Should
What's the best way to temporarily hide an installed module from a python script
I'm trying to figure out the best way to hide certain fields in user
Whats the best recommended way yo hide my staging website from search engines, i
What would be the best way to hide sensitive data from being exposed when

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.