You are looking for the setVisibility method in View .
textView.setVisibility(View.GONE); textView.setVisibility(View.INVISIBLE);
It does not take boolean because you can set it to either Invisible or Gone. If he left, he will not occupy any “space” in the layout.
source share