How do I get the Keyboard's height (Android)?

Get help using Construct 2

Post » Fri Mar 17, 2017 7:12 pm

Hi!

I've asked this some times but nobody replied :( When I run my game on Android and a text box is touched, the virtual keyboard pops up and overlaps almost 40% of the screen. I want my game to scroll up when the keyboard is on screen, but I need the keyboard's height. There is no system expression that can help (WindowHeight isn't affected).

I had thought of getting this value with an XML input and storing it as a variable, but I don't know how to do it or if this is even possible. Can you please give me a hint? I really need it and I'm sure there is a way to do it.

Thank you for your help :)
B
20
S
6
Posts: 143
Reputation: 1,666

Post » Fri Mar 17, 2017 7:18 pm

Are you sure windowheight doesn't change?

My workaround for this issue was to activate a scrollto behavior on the text box on active.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Fri Mar 17, 2017 7:23 pm

@oosyrag

I'm 100% sure, I've exported a capx that gives me WindowHeight every 2 seconds and it doesn't change. Scroll To Behaviour didn't work either (I already tried).
B
20
S
6
Posts: 143
Reputation: 1,666

Post » Fri Mar 17, 2017 8:05 pm

Try going to http://www.mbcoffice.com/wb and see how that works on your device. When I press on a field that would be covered by the OSK, it gets pushed up via scroll to to keep the box on screen. Maybe your OSK is different? If it is just an overlay and doesn't change the viewport sizes it might not work...
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Sat Mar 18, 2017 3:33 pm

@oosyrag

From this page it works, but I think it's because it is run on the browser. In built apk it doesn't work.

oosyrag wrote:If it is just an overlay and doesn't change the viewport sizes it might not work...

Yes, this is the problem. Neither ViewportBottom nor WindowHeight expressions change their values when the screen is covered by the OSK. This is why I'm looking for a way to get the OSK's height. Any clue?
B
20
S
6
Posts: 143
Reputation: 1,666

Post » Sat Mar 18, 2017 5:07 pm

I see, sorry I don't have experience with it as an apk. The first thing I would try is to scroll any activated text box to the top of the screen immediately, regardless of how much screen is left visible.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Sat Mar 18, 2017 7:38 pm

@oosyrag

Of course, this would be the "bad" solution. This is why I asked in the forum if there was any way to return the OSK's height value.
B
20
S
6
Posts: 143
Reputation: 1,666

Post » Mon Mar 20, 2017 10:27 am

Anybody? Please, I think this is an important topic and I can't be the first one to have this problem :/
B
20
S
6
Posts: 143
Reputation: 1,666

Post » Fri Mar 31, 2017 7:22 pm

Maybe a reasonable workaround would be to "ignore" WindowHeight, and just estimate maximum percentage of the screen covered by the OSK in all devices. Let's say you do some research, and you discover that the OSK never covers more than 45% of the screen in any device. It is only an estimation, but maybe it's enough. Depending on the location of the input field on the screen, you decide how much scrolling you need, always assuming the maximum % of OSK's screen coverage you've estimated.
B
11
S
3
G
1
Posts: 19
Reputation: 905

Post » Fri Mar 31, 2017 11:14 pm

I have same Problem
B
6
S
2
Posts: 26
Reputation: 548

Next

Return to How do I....?

Who is online

Users browsing this forum: Solomon and 13 guests