[英]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. 我已经通过扩展calss SurfaceView itd来自定义MySurfaceView,根据我的需要可以正常工作,但是问题是黑色背景,我希望它透明。
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. 并且我希望
timer_lay
的背景色应成为timer_lay
背景色, MySurfaceView
不是我可以在onDraw
方法中做到的。
MySurfaceView msv = new MySurfaceView(this); MySurfaceView msv =新的MySurfaceView(this); msv.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
msv.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
yes its worked for me got a solution, Thanks to g00dy 是的,对我有用的解决方案,多亏了g00dy
MySurfaceView msv = (MySurfaceView)findViewById(R.id.custom_view);
msv.setZOrderOnTop(true);
sHolder = msv.getHolder();
sHolder.setFormat(PixelFormat.TRANSPARENT);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.