Search code examples
androidsurfaceviewseekbar

How can I to make surfaceview invisible in Android?


in my app i am using a media player with a seek bar. The seek bar of works along with a surface view. Now my problem is the surface view appears at a corner of my layout which appears to be a black screen. How can i make the surface view to be an invisible. Following is the image of my layout,

enter image description here


Solution

  • You can do that 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 in the XML:

    <SurfaceView 
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:visibility="gone"/>
    

    GONE is used if you want it to be completely gone and ignored by the rest of the layout. INVISIBLE is used if you only want to change the visibility.