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
  • 37,241
  • 25
  • 195
  • 267
Jignesh Ansodariya
  • 12,583
  • 24
  • 81
  • 113
  • 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));
Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
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,583
  • 24
  • 81
  • 113