Virtual Keyboard Covering Line edit

Godot Version

Godot 4.2


uhh when i create a scene with a line edit near the bottom, when i try it on my android device the lineedit gets covered by the virtual keyboard when focused

You would need to use


And a wrapping container, this example assumes a ScrollContainer is the parent.
But it could be a “grandparent” too or whatever, you would have to adjust it.

extends LineEdit

var keyboard_height = DisplayServer.virtual_keyboard_get_height()
var scroll_container = get_parent()

func _on_line_edit_focus_entered():
  virtual_keyboard_resize(scroll_container, true)

func _on_line_edit_focus_exited():
  virtual_keyboard_resize(scroll_container, false)

func ensure_control_visible_deferred():

func virtual_keyboard_resize(control, is_visible):
    control.size.y += -keyboard_height if is_visible else keyboard_height

so i need to put scroll containers as parent on each line edit? why isnt this bug fixed already though, its been a long time since this bug existed and its still not fixed…

If you think it is a bug, you can always fix it.
Here is the open issue:

One of over 10 thousand open issues.

It’s not really a bug per say.
This problem exists in other mobile apps too. Similarly to like for a very long time in web development, centering a div both vertically and horizontally was a common layout problem.
A common solution is to change the window size on the y axis, you can use the code I gave you and adjust it to whichever solution you see fit.
Another solution in some Mobile Apps is to show a hovering input modal which is a duplicate of whichever LineEdit you have in focus.
Yet another solution is to not put inputs at the bottom of the screen so that they may be covered by a virtual keyboard.

Now, in Godot, there is yet to exist a standard, default solution for this specific problem.

If you are asking for a reason, I think it may be related to the fact that it is 1 of 10000+ open issues. Well 2, if you count the duplicate! :smiley: