0

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.

Cœur
  • 34,719
  • 24
  • 185
  • 251
Jignesh Ansodariya
  • 12,103
  • 22
  • 76
  • 108
  • try this msv.setZOrderOnTop(true); // necessary msv = msv.getHolder(); msv.setFormat(PixelFormat.TRANSPARENT); – Yogesh Tatwal Jul 03 '13 at 05:38
  • The above, taken from here http://stackoverflow.com/questions/5391089/how-to-make-surfaceview-transparent . please provide links. – g00dy Jul 03 '13 at 05:45

2 Answers2

0

MySurfaceView msv = new MySurfaceView(this); msv.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

0

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);
Jignesh Ansodariya
  • 12,103
  • 22
  • 76
  • 108