how to make surfaceview transparent

后端 未结 4 1573
[愿得一人]
[愿得一人] 2020-11-22 17:05

Hello all i want to make my DrawingSurface view transparent. i tried many thing but it\'s not working.

Here is my xml code to make my surface view transparent

<
相关标签:
4条回答
  • 2020-11-22 17:50

    TexttureView will be better for your needs than SurfaceView, i believe.

    0 讨论(0)
  • 2020-11-22 17:54

    Try this in the constructor:

    SurfaceView sfvTrack = (SurfaceView)findViewById(R.id.sfvTrack);
    sfvTrack.setZOrderOnTop(true);    // necessary
    SurfaceHolder sfhTrackHolder = sfvTrack.getHolder();
    sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);
    
    0 讨论(0)
  • 2020-11-22 17:58
    sfvTrack.setZOrderOnTop(true); 
    

    will place the surfaceView on top of the window, meaning you cannot add items on top of the surfaceView.

    If you want to add views on top of the surface view; you should consider using:

    setZOrderMediaOverlay(true);
    

    instead. This places this surfaceView on top of other surfaceViews, but still behind the window, allowing you to add other visible views on top of the surface view.

    0 讨论(0)
  • 2020-11-22 18:07

    Is your DrawingSurface and extension of SurfaceView?

    There is no way to get a SurfaceView to do what you are wanting it to do. The mechanics of the surface view are such that it can not have anything visible behind it. (see the answer here http://groups.google.com/group/android-developers/browse_thread/thread/8d88ef9bb22da574)

    I tested your hierarchy with a custom view extending SurfaceView and I see your problem. If I switch to a custom view that simply extends View, I can get transparency.

    0 讨论(0)
提交回复
热议问题