Forum Xamarin.Android

How to hide / Unhide LinearLayout section of text entry...

We are working on a test application to hide or unhide a section of an Android Application on Text Entry based on a condition of the details when the data is reloaded to the screen.

What we are attempting to do is not only HIDE the LinearLayout sections in question but to also set their heights to 0 pixels so that the Data Entry section of the screen doesn't have huge gaps between items on Data shown on the screen.

For Example:

Bill to Name
Bill to Address 1
Bill to Address 2
Bill to City
Bill to State
Bill to Zip Code
Bill to Telephone Number
.. Etc...
Is Ship to information needed (Yes / No) - Spinner

Ship to Name
Ship to Address 1
Ship to Address 2
Ship to City
Ship to State
Ship to Zip Code
Ship to Telephone Number

Then the rest of the details for the Data Entry Screen

So in the case of Ship to Information is NOT needed then hide the whole "Ship to" section on the screen along with hiding the gap on the screen.

If they later decide the "Ship to" section is needed, then show the "Ship to" section at its' proper size.

Any ideas on how to do this would be greatly appreciated.

We tried to set the height of a LinearLayout in Xamarin and it gave us a compile error saying that the item for Height is Read Only.



  • LoriLalondeLoriLalonde CAInsider, University, Developer Group Leader ✭✭✭

    Set the Visibility of the LinearLayout to Gone:


    This will ensure that the layout will not consume any space while hidden.

  • Lori,

    Thank you that works very well.

    We created 2 objects in Linear Layouts to test the theory. First one used a preloaded picture and the second one using a button.

    The ViewStates.Gone and ViewStates.Visible works extremely well.

    Thank you for your quick response.

Sign In or Register to comment.