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

**URL:** <https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Android, Widget\
**Created:** [July 4, 2023, 3:04pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267 "2023-07-04T15:04:27Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SasMaster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SasMaster](https://forums.unrealengine.com/u/SasMaster)\
**Post date:** [July 4, 2023, 3:04pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/1 "2023-07-04T15:04:27Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/0/7/a072dfde2ce0d14ce0764d602abf38bd7c2ab377.jpeg)

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:

 ![WhatsApp Image 2023-07-04 at 18.00.43](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/b/3/bb35db2a4093c0870fd423bb66b288bb9256c071.jpeg)

---

<div class="post-metadata">

**Author:** ![Paratus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Paratus](https://forums.unrealengine.com/u/Paratus)\
**Post date:** [July 7, 2023, 8:49pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/2 "2023-07-07T20:49:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![SasMaster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SasMaster](https://forums.unrealengine.com/u/SasMaster)\
**Post date:** [July 11, 2023, 7:20am UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/3 "2023-07-11T07:20:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Paratus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Paratus](https://forums.unrealengine.com/u/Paratus)\
**Post date:** [July 12, 2023, 1:32pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/4 "2023-07-12T13:32:12Z")

</div>

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:

```java
// 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
```

---

<div class="post-metadata">

**Author:** ![SasMaster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SasMaster](https://forums.unrealengine.com/u/SasMaster)\
**Post date:** [July 12, 2023, 4:29pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/5 "2023-07-12T16:29:24Z")

</div>

> [@Paratus](#):
>
> 8dp low

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 😉

---

<div class="post-metadata">

**Author:** ![Paratus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Paratus](https://forums.unrealengine.com/u/Paratus)\
**Post date:** [July 12, 2023, 8:59pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/6 "2023-07-12T20:59:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Paratus](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Paratus](https://forums.unrealengine.com/u/Paratus)\
**Post date:** [July 12, 2023, 9:26pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/7 "2023-07-12T21:26:34Z")

</div>

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:

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

---

<div class="post-metadata">

**Author:** ![SasMaster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SasMaster](https://forums.unrealengine.com/u/SasMaster)\
**Post date:** [July 13, 2023, 1:40pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/8 "2023-07-13T13:40:37Z")

</div>

> [@Paratus](#):
>
> ```auto
> // BEGIN Paratus mod
> visibleRect.bottom -= visibleRect.top;
> // END Paratus mod
> 
> ```

Yeah, this one fixes the problem. Thanks again!

---

<div class="post-metadata">

**Author:** ![Rising2014](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rising2014](https://forums.unrealengine.com/u/Rising2014)\
**Post date:** [July 16, 2023, 5:14pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/9 "2023-07-16T17:14:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SasMaster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SasMaster](https://forums.unrealengine.com/u/SasMaster)\
**Post date:** [July 19, 2023, 4:54pm UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/10 "2023-07-19T16:54:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Rising2014](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Rising2014](https://forums.unrealengine.com/u/Rising2014)\
**Post date:** [August 13, 2023, 11:30am UTC](https://forums.unrealengine.com/t/text-input-doesnt-open-in-full-height-with-virtual-keyboard-on-android/1219267/11 "2023-08-13T11:30:27Z")

</div>

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