Code Complete
Code Complete

Reputation: 43

Cannot place GLSurfaceView over SurfaceView?

My understanding is you cannot overlay two surfaceviews in Android, based on this discussion:

https://groups.google.com/forum/?fromgroups=#!topic/android-developers/COffLpanlz0

Further evidence it this does not work: GLSurfaceView/SurfaceView overlap

However I would like to know if here is a workaround? Or if perhaps this has changed with Android 4.1?

The only suggestion from google framework engineer was shown below: Does anyone know how this would be done? Or if there are any other ways to achieve this?

" It's probably not the best way, but right now you simply can not have multiple overlapping surface views in a window, so the only way to achieve this is to render the overlay in the main window. Fyi, using a separate thread and postInvalidate() is extra work that is not needed, just call invalidate() from the main thread. And you'll want to make sure that at least the part of your view hierarchy involved with drawing the overlay is as simply as possible (not deep and not a lot of views to iterate over) to reduce the overhead as much as possible." - show quoted text - [email protected]

Upvotes: 1

Views: 878

Answers (1)

Romain Guy
Romain Guy

Reputation: 98501

With Android 4.0 and higher you should use a TextureView instead. You can stack as many TextureViews as you want on top of each other. You can also animate them, etc.

Upvotes: 1

Related Questions