When you call View.setVisibility(View.INVISIBLE), you'll notice that view is still taking up space on the screen but not being drawn.
To prevent the view from leaving a big empty gap, simply use View.GONE instead of View.INVISIBLE.
To bring it back, just use View.VISIBLE.
[ Source ]