2

I am currently working on an Android App using the Python and the Kivy Framework. The majority of the screen's real estate is used by a text_input widget. I would like to resize this text_input when the android soft keyboard pops ups so that the text_input ends right at the top of the keyboard.

To accomplish this I tried to use Window.softinput_mode='resize' and when that didn't work, reference the Window.keyboard_height to do my own resize and positioning. As per the documentation and comment in the Window source code I see that both are not supported when using SDL2 on Android (Kivy 1.9 - 1.10).

I tested Window.softinput_mode='below_target' which doesn't seem to do anything and Window.softinput_mode='pan' which works but doesn't give me the correct functionality.

The last thing I tried is to set Window.softinput_mode='pan' and with a function call that is bound to the on_keyboard event print out the value of Window.top so that if the panning simply shifted the Window location upward, I could use that point of reference to do my positioning and resizing. However the value of Window.top does not apear to change when panning up.

The only other stack flow that referenced this issue and gave a working example made use of resize mode which doesn't work using SDL2.

Properly resize main kivy window when soft keyboard appears on android

Is there any work-around to accomplish this functionality or a different provider than SDL2 that will work well on Android?

Just-Joe
  • 21
  • 1
  • Am I right setting `softinput_mode=''` and binding your widget sizes to `Window.keyboard_height` doesn't work? `keyboard_height` doesn't reflect real height? – Mikhail Gerasimov Jan 20 '18 at 08:43
  • Correct. keyboard_height is always 0 for SDL2 window provider. I am trying to find out if anyone has been able to accomplish resizing based on keyboard size for a Kivy Android App either by utilizing a different approach or different window provider. – Just-Joe Jan 20 '18 at 17:09

1 Answers1

0

It seems to be a bug, so I think first step would be to report it here. May be someone will fix it or prompt you workaround.

While googling subject I found this get_keyboard_height() implementation. Since it's part of android module, try to add this recipe to your buildozer requirements. It may fix Window.keyboard_height or may just provide get_keyboard_height() function to get correct high manually.

Mikhail Gerasimov
  • 27,590
  • 10
  • 86
  • 127