开发者

How to add a text on the top of GLSurfaceview with transparent background in android?

Hi im having a parent viewgroup which has a background, contains a openglview as a part of that viewgroup.

What I want exactly is, i need a openglview with a transparent background and I want to able to see the parent background and I want to be able to write text on top of openglview, I dont want to use textures.

I tried this options,

  1. Setting the openglview zorderontop as true. It makes my text to go behind the glview. If im not making zorderontop true, the background is black.

  2. Setting the transluent theme to the activity which makes my glview and also the parent view group to become transparent.

  3. I tried to inflate the layout contains the glview and use ContexThemeWrapper class to change the theme of the glview开发者_StackOverflow社区 dynamically. But setTheme() not working at runtime. only applying theme in manifest file it works.

  4. Applying the layout backgroud to transparent also didnt work, still black background.


The problem is that you're drawing to two separate surfaces: one surface created by ViewRoot, and one surface created for the GLSurfaceView. These surfaces are composited by SurfaceFlinger, one on top of the other. (By default the ViewRoot surface will be on top and the GLSurfaceView surface will be on bottom.)

Since all of your Views are drawn into the ViewRoot's surface, they must all be on top of the OpenGL surface or beneath the OpenGL surface.

If you don't want to use textures, period, your only choice is to create a third surface, this time with SurfaceView instead of GLSurfaceView, to draw your text above the GLSurfaceView.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜