简体   繁体   English

使用SDL2在软键盘上的Kivy Android应用中调整窗口大小

[英]Resizing Window in Kivy Android App on softkeyboard with SDL2

I am currently working on an Android App using the Python and the Kivy Framework. 我目前正在使用Python和Kivy Framework开发Android应用程序。 The majority of the screen's real estate is used by a text_input widget. 屏幕的大部分空间都由text_input小部件使用。 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. 我想在android软键盘弹出时调整此text_input的大小,以便text_input恰好在键盘顶部结束。

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. 为此,我尝试使用Window.softinput_mode ='resize',如果该方法不起作用,请参考Window.keyboard_height进行自己的调整大小和定位。 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). 根据Window源代码中的文档和注释,我看到在Android(Kivy 1.9-1.10)上使用SDL2时,两者均不受支持。

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. 我测试了Window.softinput_mode ='below_target'似乎什么都没做,并且测试了Window.softinput_mode ='pan'可以工作,但没有给我正确的功能。

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. 我尝试的最后一件事是设置Window.softinput_mode ='pan',并使用绑定到on_keyboard事件的函数调用来打印出Window.top的值,这样,如果平移只是将Window位置向上移动,我可以使用该参考点可做我的定位和调整大小。 However the value of Window.top does not apear to change when panning up. 但是,平移时,Window.top的值不会改变。

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. 引用此问题并给出工作示例的唯一其他堆栈流程使用了调整大小模式,而调整大小模式不适用于SDL2。

Properly resize main kivy window when soft keyboard appears on android 当软键盘出现在android上时适当调整主Kivy窗口的大小

Is there any work-around to accomplish this functionality or a different provider than SDL2 that will work well on Android? 是否有任何解决方法可以实现此功能,或者与SDL2不同的提供程序可以在Android上正常运行?

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 . get_keyboard_height()主题时,我发现了此get_keyboard_height() 实现 Since it's part of android module, try to add this recipe to your buildozer requirements. 由于它是android模块的一部分,请尝试将此食谱添加到您的buildozer要求中。 It may fix Window.keyboard_height or may just provide get_keyboard_height() function to get correct high manually. 它可以修复Window.keyboard_height ,也可以只提供get_keyboard_height()函数以手动获得正确的高位。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kivy SDL2 Python3.5构建在Android 5及更高版本上崩溃 - Kivy SDL2 Python3.5 build crashing on android 5 and above Python 3.7.7 Kivy:找不到任何有价值的 Window 提供程序。 sdl2 - ValueError: 不是 boolean: 400 - Python 3.7.7 Kivy: Unable to find any valuable Window provider. sdl2 - ValueError: Not a boolean: 400 在Kivy中使用sdl2而不是pygame - using sdl2 in Kivy instead of pygame 使用SDL2在centos 7上运行kivy 1.9.1 - Run kivy 1.9.1 with SDL2 on centos 7 尝试使用 Python27 运行 Kivy 应用程序时出错:引发异常('SDL2:无法加载图像') - Error when trying to run Kivy app with Python27: raise Exception('SDL2: Unable to load image') 例外:SDL2:无法加载图像 - 在 android 上运行 kivy apk 时 - Exception: SDL2: Unable to load image - When running kivy apk on android Kivy 无法在 Raspberry Pi 4 上打开窗口,原因是缺少 x11 服务器,即使窗口提供程序是 SDL2 - Kivy can't open a window on Raspberry Pi 4, cites a lack of x11 server even though window provider is SDL2 sdl2 - ImportError: DLL load failed: The specified module could not be found and [CRITICAL] [App] Unable to get a Window, abort - sdl2 - ImportError: DLL load failed: The specified module could not be found and [CRITICAL] [App] Unable to get a Window, abort 如何让 Kivy 在 Linux 上使用 sdl2? - How can I get Kivy to use sdl2 on Linux? Kivy sdl2 - 运行时错误:b'无法初始化 EGL - Kivy sdl2 - RuntimeError: b'Could not initialize EGL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM