Text input doesn't open in full height with virtual keyboard on Android

I am using Unreal Engine 5.2.
I have a text input field which is supposed to be used to write text messages. My target platform are mobile phones running Android OS.
While testing this feature I found that once the text field gets focus with the virtual keyboard on the screen, the first line of the text input is half hidden. If I don’t break the line with pressing enter, it stays like that. See image below

I tested the app on more than one Android phone and the results is the same.
Is it a bug, or I am missing something here? I tried all the input types and it is always the same end result.
Another thing I see I cannot get right is having another widget at the same line as the input field on top of the virtual keyboard. E.g a button like in whatsapp messenger. How can I make it stick to the top edge of the keyboard? Like this:

This seems to be a bug in 5.2 with portrait views, but not landscape. I guess most people don’t notice as landscape is the default.

1 Like

I haven’t found a solution yet. Submitted a bug to Epic.

I noticed that Google Play created a bug report/screenshot for this overlap and it mentioned it was 8dp low. This is not likely the proper fix, it’s hacky since it’s hardcoded at 8dp without considering the source but if you want a quick hacky fix do this:

Open Engine\Build\Android\Java\src\com\epicgames\unreal\GameActivity.java.template.

Find the line that looks like this:
int bottomDiff = Math.abs( mainDecorViewRect.bottom - visibleRect.bottom );

Paste this block below that line:

// BEGIN Paratus mod
// Get the pixels per dp value based on the current device screen density
float pixelsPerDp = getResources().getDisplayMetrics().density;

// Convert 8dp to pixels
int pixelsToMove = (int) (8 * pixelsPerDp);

// Move visibleRect.bottom up by the calculated pixel value
visibleRect.bottom -= pixelsToMove;
// END Paratus mod

What is 8 here? Font size? In my case font size is 24 so I replaced 8 with 24 and it looks correct now. with 8 I am getting still half height hidden. Will use your hack till they fix it.
Huge thanks, I owe you a beer :wink:

8’s DP, not in pixels. I think the full height of the text box is 24 (I may be wrong, I forget). But the issue is that it seems to be theme specific. The amount it needs to move is different on different phones. On my Galaxy S23 Ultra, 10 was the magic number. However on a pixel it needed more around 24. The issue seems to be related to the action bar up top. Maybe the camera notch? Different phones need different spacing and I haven’t dug into it.

In other words, what you’re doing now may look fine but it might not on other phones.

To fix this in portrait, modify the file
Engine\Build\Android\Java\src\com\epicgames\unreal\GameActivity.java.template

Find the line that looks like this:
int bottomDiff = Math.abs( mainDecorViewRect.bottom - visibleRect.bottom );

Add the following code below it:

// BEGIN Paratus mod
visibleRect.bottom -= visibleRect.top;
// END Paratus mod

Yeah, this one fixes the problem. Thanks again!

Thank you very much, this did solve the problem, you are a real master.

Maybe at the same occasion anyone can explain how to put a button near the text field when the virtual keyboard is open? I need to make it look like Whatsapp messenger.

It would be amazing if it could achieve the same effect as Whatsapp Messenger! Please let me know if you achieve it.