Android GLSurfaceView as subview
I'm very new to an Android platform and currently trying figure out why things work 开发者_Python百科this way:
If I create GLSurfaceView
and add it using the setContentView
or addContentView
to an activity everything works fine (Renderer.onDrawFrame
is called as expected). However if I add my GLSurfaceView
to another ViewGroup
(which is then added using setContentView
) nothing is rendered.
So what is the difference between addView
and addContentView
?
In the end I need to create a custom view with OpenGL rendering in background and some controls on top.
Also what is the point of separating View and ViewGroup? Why not to join them (like it is done in CocoaTouch) ?
setContentView(View)
sets the parent View
for an Activity (or dialog etc...).
addView(View)
adds a View
to a ViewGroup
.
View
and ViewGroup
are mostly different. View
is a more specific single entity. It should be used more on one facet of what you are trying to do. ViewGroup
, however, focuses more on the whole and acts (is) a container and layout organizer for a collection of View
s.
Can you post all the code related to the GLSurfaceView and how you are setting it as contentView?
精彩评论