SurfaceView transparency problem - android

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 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.

Related

When using GLSurfaceView, all other Android views are displayed as black rectangle

When using GLSurfaceView, all other Android views are displayed as black rectangle, no rendering happens for any other views other than the GLSurfaceView. How to fix this?
This is fixed by setting MainActivity background to have some solid color. It is transparent by default and the other views isn't rendered.

Android - Make camera preview semi-transparent

I want to make my camera preview see through. I saw this following post:
how to make surfaceview transparent
About making a surface view transparent but the problem is that I am extending surface view for more control over the camera and they say that extending the surface view will make this solution invalid and don't explain why/propose another solution.
What can I do to achieve this?
EDIT:
Yes, I have tried what is in the Linked Post.
THIS IS WHAT I WANT TO ACHIEVE
TOP
=================================
SEMI-TRANSPARENT CAMERA PREVIEW
[FULLSCREEN]
=================================
IMAGES AND TEXT
=================================
BOTTOM
Place another view over your Preview view and make that view semi-transparent. To make view semi-transparent you have to give alpha value with color to the background
ex:
<View
android:background=#88000000/>

TextureView and Transparency

I have a TextureView with a mediaPlayer attached to it, so i can use its surface to display a video, so far it's working well.
Now i try to create a fade in animation for displaying the video and i have no clue of how to do it.
I tried with the setOpaque(false) setting and playing with the alpha setting but it doesn't have any effects.
Also i tried the textureView without a mediaPlayer and i notice that i can't change the background color either, it's always black.
The documentation say that the behaviour of this view is the same as the standard view, but it doesn't seem to be the case.
Does anyone know how to change the transparency of this view ?
Thanks
I also had this problem, and you just need to set setAlpha(0.999f) and it will have transparent background.

Android: how can you tell that a View has become Visible?

I have a FrameView containing a full-screen ImageView on top and a full-screen SurfaceView underneath. The ImageView starts out INVISIBLE while I display the SurfaceView. Now I set the ImageView to VISIBLE and want to update what is on the SurfaceView, unseen.
But the ImageView is not yet really visible. I have to wait until the ImageView is actually visible before messing with the SurfaceView. How is this done?
The only way I found was to wait 50ms (nothing less would do) before messing with the SurfaceView. Which happens to work reliably on my device, but is obviously a hack.
To be more specific: on the SurfaceView I am preparing a movie. Which makes the screen go black. I am trying to avoid the black by covering it with an image.
Any help appreciated!
You can use View.onVisibilityChanged().

Transparent RelativeLayout which sits "on top" of a surfaceview?

I've got a canvas drawn (I have to keep the canvas, it's doing other things). I'm drawing N amount of images in this canvas, I'm wondering how would I make them clickable? also does anyone know how I could test if a bitmap is in a certain co-ord? Alternatively how would I create a button which was an image on a canvas? or even, How would I create a Transparent RelativeLayout on top of a Surfaceview?
edit.. anyone?? I'm thinking Relative Layout on top of Surfaceview would be the best way to go!
edit2: Setting things to transparent seems to just set the background to black and not actually let me see the Surfaceview I have defined under it.
Thanks,
Turns out it's already transparent and setting it to transparent just makes it black! you also just use bringtofront(); in order to make it sit "on top" of anything.

Categories

Resources