You can do this by setting the visibility in the code:
surfaceView.setVisibility(View.GONE)or surfaceView.setVisibility(View.INVISIBLE).
And you can do the same by setting it to XML:
<SurfaceView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="gone"/>
GONE is used if you want it to completely disappear and be ignored by the rest of the layout. INVISIBLE is used if you want to change the visibility.
source
share