I have a class within my game which I copied from a tutorial:
public class PanelThing extends SurfaceView implements SurfaceHolder.Callback
{
}
I never quite understood how this class worked, but it seems to do the job and my game has been working fine for some time. This PanelThing seems to operate a bit like some kind of Layout. In my game’s onCreate method I have:
pt = new PanelThing(this);
game_play_layout = new LinearLayout(this);
game_play_layout.addView(pt);
setContentView(game_play_layout);
Now I need to have a child layout within pt. I tried doing pt.addView(my_child_layout), but addView is undefined within pt. Is it possible to modify PanelThing, perhaps with “extends” or “implements” so that addView becomes defined? Or is there some other way I can add a layout to pt?
EDIT: If you want to know exactly why I want a child layout for pt, see this question.
a
SurfaceViewis not a layout container likeLinearLayoutso you can’t add views to it. It’s more like an interactive image you draw in your code all the time.You’ll either have to add the additional information you want to display to the drawing code of your
SurfaceViewor you could layout it on top of yourSurfaceViewusing aFrameLayout. Make sure that the layout on top is transparent in those regions you don’t want to block the content below.