Android : difference between invisible and gone?
From Documentation you can say that
View.GONE This view is invisible, and it doesn't take any space for layout 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
Now if you set visibility of Button Two as invisible (View.INVISIBLE
), then the output will be
And when you set visibility of Button Two as gone (View.GONE
) then the output will be
Hope this will clear your doubts.
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.
INVISIBLE:
The view has to be drawn and it takes time.
GONE:
The view doesn't have to be drawn.
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