简体   繁体   English

隐藏Android键盘键预览

[英]Hide Android keyboard key preview

What I'm looking to do is hide only the popups that show what key you are currently pressing while using a soft keyboard. 我要做的是隐藏弹出窗口,显示当前正在按下的键,同时使用软键盘。 Is this possible? 这可能吗? I am creating my own new keyboard which will have no need for them. 我正在创建我自己的新键盘,它不需要它们。

From what I think I understand, the picture below is the actual popup keyboard that you can choose to show using android:popupKeyboard and android:popupCharacters in the Keyboard.Key XML. 根据我的理解,下面的图片是您可以选择在Keyboard.Key XML中使用android:popupKeyboardandroid:popupCharacters显示的实际弹出键盘。

弹出Android键盘

But the image below is not the same (also see this picture ). 但下面的图片并不相同(也见此图片 )。 Is there a way to turn the following off, using XML or even programmatically? 有没有办法使用XML甚至以编程方式关闭以下内容?

Android键盘弹出窗口

After reading a little bit of the actual android keyboard source code : 看了一下实际的android键盘源代码

What I was referring to was the "key preview", which is "a popup that shows a magnified version of the depressed key." 我所指的是“关键预览”,这是一个“弹出窗口,显示了按下的按键的放大版本”。 By default the preview is enabled, but to disable it, simply enough, is setPreviewEnabled(boolean previewEnabled) . 默认情况下,预览已启用,但要禁用它,简单就是setPreviewEnabled(boolean previewEnabled) Which is a method from the KeyboardView class. 这是KeyboardView类的一个方法。 API . API

public void onPress(int primaryCode) {
     mInputView.setPreviewEnabled(false);
}

public void onRelease(int primaryCode) {
    mInputView.setPreviewEnabled(true); //Change to false if you want remove too for the Del key when it's pressed
}

Additionally, To get the view and universally disable the preview from within a custom class extending InputMethodService 此外,要从扩展InputMethodService的自定义类中获取视图并普遍禁用预览

    private KeyboardView mInputView;
    @Override
    public KeyboardView onCreateInputView() {
        mInputView = (KeyboardView)getLayoutInflater().inflate(R.layout.keyboard, null);
        mInputView .setPreviewEnabled(false);
        return mInputView;
    }

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM