开发者

SurfaceView transparency problem

开发者 https://www.devze.com 2023-04-01 00:05 出处:网络
I have this problem: i added two view instances in a framelayout. First view is a VideoView which plays in loop a video. Second view is placed above the videoview and is a surfaceview. The surfaceview

I have this problem: i added two view instances in a framelayout. First view is a VideoView which plays in loop a video. Second view is placed above the videoview and is a surfaceview. The surfaceview draws some .png's an a white rectangle which needs a small part of the screen. The part that is not needed must be transparent. in order to do that i used the next code lines (surfaceview implemnts开发者_StackOverflow中文版 SurfaceHolder.Callback):

setZOrderOnTop(true);
getHolder().setFormat(PixelFormat.Transparent);

The problem is that i want to make the white rectangle semitransparent in order to see the movie played by the videoview. The transparency effect works fine on the non used part of the surfaceview but the rectangle does not became semitransparent(if a i draw a background to surfaceview the effect becomes visible.) I wait a solution from u guys.Thx


Maybe the SurfaceHolder doesn't allow alpha. Have you checked the result of PixelFormat.formatHasAlpha()? Or have you tried explicitly setting PixelFormat.RGBA_4444, RGBA_5551 or RGBA_8888 to see what happens?


mVideoView.setZOrderOnTop( true );
getHolder().setFormat( PixelFormat.RGBA_8888 );

Worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号