如何与QUOT;推升"当显示软时,键盘屏幕 [英] How to "push up" the screen when soft keybord is displayed

查看:195
本文介绍了如何与QUOT;推升"当显示软时,键盘屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的LibGDX And​​roid应用程序表,下面的一些文本框(一行)和下方的按钮(提交)。
我的问题是,如何滑出表,textfiels当文本框为重点(点击它)和软键盘显示的按钮?
换句话说,如何让软键盘的的覆盖我的其他对象。
该解决方案的可能的与此相关的问题:
<一href=\"http://stackoverflow.com/questions/20410132/how-can-i-find-the-height-of-soft-keyboard-in-a-libgdx-application\">How我能找到的软键盘的高度在LibGDX应用

I have in my LibGDX android application a table, below some textfields (one row) and a button below (Submit). My question is, how to "slide" up the table, textfiels and the button when the textfield is focuses (click on it) and the soft keyboard is appearing? In other words, how to make the soft keyboard not to cover my other objects. This solution might be related with this question: How can i find the height of soft-keyboard in a LibGDX application

非常感谢。

推荐答案

我发现我的问题的解决方法,它的工作,但我不认为这是太干净。
所以,我的情况是:

I found an workaround for my problem, it's working, but I don't think is too clean. So, my scenario was:


  • 的容器中,则包含一个ScrollPane(另一个表),该表的滚动下的两个文本字段和他们下一个提交按钮

  • 容器表中设置,以填补父(全屏)

  • 对准到容器表的底部的文本字段和按钮

的问题是,当OnscreenKeybord是可见的,它覆盖了底部对象(文本字段和按钮),滚动表的一部分。

The problem was that when the OnscreenKeybord was visible, it covered the bottom objects (text fields and button) and a part of the scrolling table.

我的解决方案/解决方法是:

My solution / workaround is:

    keyboard = new OnscreenKeyboard() {
        @Override
        public void show(boolean visible) {
            Gdx.input.setOnscreenKeyboardVisible(visible);
            // Hmmmm...
            container.invalidate();
            if (visible) {
                // TODO get OsK height somehow!!!
                container.padBottom(310);
            } else {
                container.padBottom(0);
            }
        }
    };
    textFld1.setOnscreenKeyboard(keyboard);
    textFld2.setOnscreenKeyboard(keyboard);

和提交按钮的InputListener(上触地)我有一个像清理功能:

and on the InputListener of the Submit button (on touchDown) I have a cleanup function like:

    textFld1.setText("");
    textFld2.setText("");
    stage.unfocus(textFld1);
    stage.unfocus(textFld2);
    keyboard.show(false);

在这种方式的容器表将被填充了当显示软键盘,它会提交按钮之后再进行还原pressed;也软键盘是隐藏的。

In this way the container table will be padded up when the soft keyboard is displayed and it will be restored after the submit button is pressed; also the soft keyboard is hidden.

现在,有两个问题解决方法:

Now, there are two problems with this workaround:


  • 我还没有找到一种方式来获得软键盘高度;你可以在样本code看到我已经选择了向上填充任意值,所以吊环好看我的模拟器

  • I have not found a way to get the soft keyboard height; as you can see in the sample code I have chosen an arbitrary value for the up padding, so the tings to look good on my emulator

如果硬键返回或ESC在模拟器pressed,软键盘将隐藏,但该表的上边距将仍然存在;我没有发现的如何的确定软键盘是可见或不可见

if hard button Back or ESC in emulator is pressed, the soft keyboard will hide, but the up-padding of the table will still be there; I didn't find how to determine if the soft keyboard is visible or not

如果有人发现我的问题的另一个解决方案,请张贴。

If anyone finds another solution for my problem, please post it.

感谢。

这篇关于如何与QUOT;推升&QUOT;当显示软时,键盘屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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