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

0 favourites
  • 11 posts
From the Asset Store
Take your creativity to new heights with over 410+ files.
  • 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

  • Are you sure windowheight doesn't change?

    My workaround for this issue was to activate a scrollto behavior on the text box on active.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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).

  • 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...

  • 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.

    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?

  • 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.

  • 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.

  • Anybody? Please, I think this is an important topic and I can't be the first one to have this problem :/

  • 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.

  • I have same Problem

  • arturosanz Yes, this is what I've done. Thanks.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)