-
-
Notifications
You must be signed in to change notification settings - Fork 22.8k
Fix immersive mode and virtual keyboard height issue on Android #108287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix immersive mode and virtual keyboard height issue on Android #108287
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
@llama-nl It might not work on embedded window. Can you test with exported project, or try disabling embedded window and with gamebar hidden. |
@syntaxerror247 ok, it works in protrait mode. I think it doesn't working in landscape mode? |
That's an issue with the MRP project. Stretch mode is set to To fix this, either set stretch mode to
|
It works great on Android 12 for me, but on Android 9 it always returns 0 regardless if the keyboard is visible or not. |
e844e5e
to
ff3c944
Compare
@kilojool The method used to calculate the virtual keyboard height is only available on Android 11 and above. I’ve now added support for older versions as well. Could you please test it again and let me know if it works now? |
ff3c944
to
63aacd5
Compare
@syntaxerror247 Yes, that fixed it for me on Android 9 also! Nice work! =D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test project: NavigationBarProblem.zip
Tested on Samsung Tab S7 (Android 13) and LG Nexus 5X (Android 8)
I had to modify MRP, disable Gradle build (Godot 4.3 custom mods, probably no longer compatible), and take scaling into account.
func _process(_delta):
#https://github.com/godotengine/godot/issues/86663#issuecomment-2132230189
var keyboard_height := DisplayServer.virtual_keyboard_get_height()
self.size.y = get_viewport_rect().size.y - (keyboard_height / get_viewport_transform().get_scale().y)
On the LG Nexus 5X (Android 8), there are problems when Immersive mode is enabled. As soon as the keyboard appears, Immersive mode is exited. Probably OS specific. On Samsung Tab S7 (Android 13), I couldn't find any issues.
Video: Issues / Test LG Nexus 5X, Immersive mode + Edge To Edge
nexus_5x.mp4
Input field is suddenly behind the navigation bar when the keyboard is hidden again.
I also noticed issues with immersive/edge-to-edge mode on android 9 (emulator), I'm looking into it. |
63aacd5
to
80cce84
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works better than before on Nexus 5X Android 8, in Immersive Mode
.
However, if Immersive Mode
is disabled and Edge to Edge
is enabled, the input field behind the navigation bar disappears. Partially on the Samsung Tab S7, and completely on the Nexus 5X.
Test project: NavigationBarProblem.zip
Now the function returns 0 (Android 8) if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
Can you reproduce it? Otherwise, I'll check it more closely on my device later.
That's an exected behaviour. App shouldn't place any interactable node at bottom, if using use edge-to-edge mode. |
Yes, I can reproduce this on an Android 7 emulator (not reproducible on Android 9; I haven't tested on 8). We have two possible solutions:
|
Fixes #86663
This PR fixes the incorrect virtual keyboard height issue and adds support on API 29 and older.
Fixes all the known immersive and edge-to-edge mode issues.