Android : difference between invisible and gone? Android : difference between invisible and gone? android android

Android : difference between invisible and gone?


INVISIBLE:

This view is invisible, but it still takes up space for layout purposes.

GONE:

This view is invisible, and it doesn't take any space for layout purposes.


From Documentation you can say that

View.GONE This view is invisible, and it doesn't take any space forlayout purposes.

View.INVISIBLE This view is invisible, but it still takes up space for layout purposes.


Lets clear the idea with some pictures.

Assume that you have three buttons, like below

enter image description here

Now if you set visibility of Button Two as invisible (View.INVISIBLE), then the output will be

enter image description here

And when you set visibility of Button Two as gone (View.GONE) then the output will be

enter image description here

Hope this will clear your doubts.


For ListView or GridView there is an another difference, when visibility initially set to

INVISIBLE:

Adapter's getView() function called

GONE:

Adapter's getView() function didn't call, thus preventing views to load, when it is unnecessary