Kivy TextInput位于Android键盘上方,但屏幕其余部分保持原样 [英] Kivy TextInput to be above Android keyboard, however rest of screen to stay where it is

查看:128
本文介绍了Kivy TextInput位于Android键盘上方,但屏幕其余部分保持原样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Kivy构建一个问答游戏,该游戏的屏幕底部为用户提供了TextInput选项.它在底部,因为答案的线索显示在顶部.

I am building a quiz game in Kivy, that has a TextInput option for users at the bottom of the screen. It's at the bottom because the clues for the answers are displayed at the top.

我遇到的问题是,当我将应用程序部署到手机上时,会弹出Android屏幕键盘,并阻塞近一半的屏幕.

The issue I am having is when I deploy my app to my phone, the Android on-screen keyboard pops up and blocks out nearly half my screen.

我在Windows软件包中尝试了softinput_mode,但是这似乎使我的整个屏幕向上推,因此现在屏幕的上半部分消失了(用户无法再看到线索).

I tried the softinput_mode in the Windows package, but this seems to push my entire screen up and so now, the top half of the screen is gone (and users can no longer see the clues).

是否可以将其合并到我的TextInput框所在的FloatLayout中?

Is there a way to incorporate this within the FloatLayout where my TextInput box is?

如果有帮助,下面的示例代码将帮助您重现问题并了解我的意思:

If it helps, here is a sample code that will help you recreate the issue and see what I mean:

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)

非常感谢您提供有关如何解决此问题的帮助,谢谢!

Would really appreciate any help on how to get this bit fixed, thank you!

推荐答案

您是否尝试过下面列出的其他选项?

Did you try another options listed below?

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

这篇关于Kivy TextInput位于Android键盘上方,但屏幕其余部分保持原样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆