Python Kivy TextInput将位于Android键盘之上,但屏幕的其余部分将保持不变
我正在用Kivy开发一个问答游戏,在屏幕底部为用户提供一个文本输入选项。它位于底部,因为答案的线索显示在顶部 我遇到的问题是,当我将我的应用程序部署到手机上时,Android屏幕上的键盘弹出,挡住了我近一半的屏幕 我在Windows软件包中尝试了Python Kivy TextInput将位于Android键盘之上,但屏幕的其余部分将保持不变,python,kivy,kivy-language,Python,Kivy,Kivy Language,我正在用Kivy开发一个问答游戏,在屏幕底部为用户提供一个文本输入选项。它位于底部,因为答案的线索显示在顶部 我遇到的问题是,当我将我的应用程序部署到手机上时,Android屏幕上的键盘弹出,挡住了我近一半的屏幕 我在Windows软件包中尝试了softinput\u模式,但这似乎将我的整个屏幕向上推,因此现在,屏幕的上半部分消失了(用户再也看不到线索) 有没有办法将其合并到文本输入框所在的FloatLayout中 如果有帮助,下面是一个示例代码,可以帮助您重新创建问题,并了解我的意思: mai
softinput\u模式
,但这似乎将我的整个屏幕向上推,因此现在,屏幕的上半部分消失了(用户再也看不到线索)
有没有办法将其合并到文本输入框所在的FloatLayout中
如果有帮助,下面是一个示例代码,可以帮助您重新创建问题,并了解我的意思:
main.py:
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.core.window import Window
Window.softinput_mode = "below_target"
class TestBox(BoxLayout):
pass
class RVTestApp(App):
def build(self):
return TestBox()
RVTestApp().run()
.kv文件:
<GameWindow>:
FloatLayout:
Label:
pos_hint: {'center_x': 0.5, "center_y": 0.9}
size_hint: (0.2, 0.5)
font_size: 80
color: 0, 0, 0, 1
text: "TEXT AT TOP OF SCREEN"
TextInput:
pos_hint: {'x': 0.25, 'y': 0.05}
size_hint: (0.3, 0.05)
id: guess
multline:False
Button:
text: "CHECK BUTTON FOR ANSWERS AT BOTTOM OF SCREEN"
pos_hint: {"x": 0.6, "y": 0.05}
size_hint: (0.3, 0.05)
:
浮动布局:
标签:
位置提示:{'center_x':0.5,“center_y”:0.9}
尺寸提示:(0.2,0.5)
字号:80
颜色:0,0,0,1
文本:“屏幕顶部的文本”
文本输入:
位置提示:{'x':0.25,'y':0.05}
尺寸提示:(0.3,0.05)
我猜
莫特琳:错
按钮:
文本:“检查屏幕底部的答案按钮”
pos_提示:{“x”:0.6,“y”:0.05}
尺寸提示:(0.3,0.05)
非常感谢您对如何修复这一点的帮助,谢谢 您是否尝试了下面列出的其他选项
+----------------+-------------------------------------------------------+
| Value | Effect |
+================+=======================================================+
| '' | The main window is left as is, allowing you to use |
| | the :attr:`keyboard_height` to manage the window |
| | contents manually. |
+----------------+-------------------------------------------------------+
| 'pan' | The main window pans, moving the bottom part of the |
| | window to be always on top of the keyboard. |
+----------------+-------------------------------------------------------+
| 'resize' | The window is resized and the contents scaled to fit |
| | the remaining space. |
+----------------+-------------------------------------------------------+
| 'below_target' | The window pans so that the current target TextInput |
| | widget requesting the keyboard is presented just above|
| | the soft keyboard. |
+----------------+-------------------------------------------------------+
您是否尝试了下面列出的其他选项
+----------------+-------------------------------------------------------+
| Value | Effect |
+================+=======================================================+
| '' | The main window is left as is, allowing you to use |
| | the :attr:`keyboard_height` to manage the window |
| | contents manually. |
+----------------+-------------------------------------------------------+
| 'pan' | The main window pans, moving the bottom part of the |
| | window to be always on top of the keyboard. |
+----------------+-------------------------------------------------------+
| 'resize' | The window is resized and the contents scaled to fit |
| | the remaining space. |
+----------------+-------------------------------------------------------+
| 'below_target' | The window pans so that the current target TextInput |
| | widget requesting the keyboard is presented just above|
| | the soft keyboard. |
+----------------+-------------------------------------------------------+