Andengine: add a view containing user interface controls on top of andengine using addContentView

I am trying to create an EditText on top of andengine game to act as a game chat. The method I use works fine on Android 2.2.1 IDEOS 2, Android 2.1 emulator, Android 2.2 emulator, Android 2.3 emulator .

UPDATE 25 / APR / 2012 : Recently tested on the Samsung Galaxy S SGH-T959 Android 2.1-Update1, it works fine, except for minor alignment problems, this is an Android 2.3 problem on Samsung.

The following devices do not display the EditText control on top of andengine game activity:

  • Samsung Y S5360 Android 2.3.6
  • Samsung Galaxy 551 Android 2.3.6

This is what I do in gaming

chatEditText = new EditText(this); chatEditText.setSingleLine(true); chatEditText.setId(1); chatEditText.setHint(" "); tableLayout = new TableLayout(this); tableLayout.setVerticalGravity(Gravity.BOTTOM); tableLayout.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); tableLayout.setHorizontalGravity(Gravity.CENTER_HORIZONTAL); tableLayout.setPadding(25, 25, 25, 308); tableLayout.addView(chatEditText); LayoutParams lp = new ViewGroup.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); this.addContentView(tableLayout, lp); tableLayout.setVisibility(View.GONE); 

To show / hide the control, I set its visibility to View.VISIBLE or View.GONE, if required, using a handler.

The above work on IDEOS 2 Android 2.2.1 and emulators, but not on the Samsung Galaxy 551, Samsung Galaxy S 5360, you need to check on other devices. Please, help.

The above method has been described here: AndEngine forum displaying the user interface in andengine Another method was proposed in which the popup dialog displays EditText here the input class of the AndEngine helper class , but this is not suitable for my use.

I would like to use the standard EditText, otherwise the only way out is to implement my own fake keyboard and fake sprite input in AndEngine, with the restriction that hardware and international keyboards may not be available. Any help would be appreciated.

+6
source share

Source: https://habr.com/ru/post/913333/


All Articles