Is there a difference between the visibility of a view.GONE or false?

Asked

Viewed 527 times

5

I would like to know which of these implementations is the correct one?

tlb.setVisibility(View.GONE); 

or

tlb.setVisibility(false);

What’s the difference between them?

  • With setVisibility( false ) the object does not appear, but becomes empty space on the screen, while setVisibility( View.GONE ) does not leave empty space.

  • Uia!!! Just that? I get it. So I should prefer Gone?

2 answers

5


In accordance with the documentation , the method setVisibility calls for a int, and not a boolean!

You can use three options:

  1. View.VISIBLE (Being shown)

  2. View.INVISIBLE (Not displayed but occupies the screen space)

  3. View.GONE (Does not display and does not occupy the screen space)

I believe if you try to pass one boolean in this method, the following error shall occur:

Error:: no suitable method found for setVisibility(Boolean) method View.setVisibility(int) is not applicable (argument Mismatch; Boolean cannot be converted to int) method Imageview.setVisibility(int) is not applicable (argument Mismatch; Boolean cannot be converted to int) method Visibilityawareimagebutton.setVisibility(int) is not applicable (argument Mismatch; Boolean cannot be converted to int)

  • how stupid I am. I understood!!!

  • 1

    I liked INVISIBLE. Because I can set it to appear later and it doesn’t get crooked on the screen if I need to appear...

4

The estate Gone causes the view to be treated as if it did not exist while the Invisible he’s simply invisible, so yes there’s a difference.

  • I don’t understand.....

  • but if it does not exist and if it is not visible it has difference?

  • It’s because if it’s invisible you can align and position another view based on this invisible one, now if it doesn’t exist you can’t do it. It’s more for alignment issues and even visuals.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.