I am trying to add a "PlayerName" box on top of a opengl menu background, is this possible? I've tried various layouts, but they don't seem to allow an EditText box to appear on top

What is the typical way of doing something like this? Do I need to manually render the text and handle input or is there a better way? It seems like it should be possible to show the EditText on top of the GLSurfaceView somehow.

| improve this question | | | | |
  • \$\begingroup\$ I ended up implementing an EditBox manually to deal with text input. It wasn't too difficult although not as full featured as I'd like. \$\endgroup\$ – Ash McConnell Apr 21 '11 at 13:23

I found the correct way of doing this (This code is in the Activity class)

view = new MyGLSurfaceView(this, gameHandler);
editBox = new EditText(context);
editBox.setText("Hello Matron");

view.setRenderer(new OpenGLRenderer(gameHandler));

addContentView(editBox, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

The key is using addContentView method on the Activity class to add the editBox on top of the GLSurfaceView.

Hope this helps some googlers :)

Thanks! Ash

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.