Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Android keyboard key preview

Tags:

android

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.

Popup Android Keyboards

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?

Android Keyboard Popups

like image 962
Whymarrh Avatar asked Apr 03 '12 15:04

Whymarrh


People also ask

How do I stop the keyboard from appearing on my Android screen?

Going to settings app and selecting Apps & notifications:And finally clicking on Android Keyboard (AOSP) entry in the app list: Clicking on Disable button and confirming in a pop-up dialog will disable on-screen android keyboard from appearing when trying to type.


2 Answers

After reading a little bit of the actual android keyboard source code:

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). Which is a method from the KeyboardView class. API.

like image 187
Whymarrh Avatar answered Sep 30 '22 12:09

Whymarrh


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

    private KeyboardView mInputView;
    @Override
    public KeyboardView onCreateInputView() {
        mInputView = (KeyboardView)getLayoutInflater().inflate(R.layout.keyboard, null);
        mInputView .setPreviewEnabled(false);
        return mInputView;
    }
like image 27
highpass Avatar answered Sep 30 '22 12:09

highpass