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

5

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

tlb.setVisibility(View.GONE); 

or

tlb.setVisibility(false);

What's the difference between them?

    
asked by anonymous 23.01.2017 / 14:09

2 answers

5

According to the documentation , the setVisibility method requests a int , and not a boolean !

You can use three options:

  • View.VISIBLE

  • View.INVISIBLE (Not displayed but takes up the space in screen)

  • View.GONE (Not displayed and does not take up space on screen)

  • I believe that if you try to pass a boolean on this method, the following error should occur:

      

    Error: no suitable method found for   setVisibility (boolean) method View.setVisibility (int) is not   applicable (argument mismatch; boolean can not be converted to int)   method ImageView.setVisibility (int) is not applicable (argument   mismatch; boolean can not be converted to int) method   VisibilityAwareImageButton.setVisibility (int) is not applicable   (argument mismatch; boolean can not be converted to int)

        
    23.01.2017 / 14:20
    4

    The property Gone causes the view to be treated as if it did not exist while Invisible is simply invisible, so it does have a difference.

        
    23.01.2017 / 14:12