Search code examples
androidsurfaceview

Custom SurfaceView Make transparent in Android


I have made a custom MySurfaceView by extending calss SurfaceView itd working fine as per my need but problem is black background I want it transparent.

My code like this.

lay = (LinearLayout)findViewById(R.id.timer_lay);

    MySurfaceView msv = new MySurfaceView(this);
    lay.addView(tv);

and I want that the the background color of timer_lay should become background color of MySurfaceView than I can I do this in onDraw method.


Solution

  • yes its worked for me got a solution, Thanks to g00dy

    MySurfaceView msv = (MySurfaceView)findViewById(R.id.custom_view);
    msv.setZOrderOnTop(true);   
    sHolder = msv.getHolder();
    sHolder.setFormat(PixelFormat.TRANSPARENT);