Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
333 views
in Technique[技术] by (71.8m points)

android - How do you disable the SoftKeyboard key preview window?

When creating your own SoftKeyboard you are given a "key preview" by default.

enter image description here enter image description here

How do you disable this?

Edit:

You can customise the keyPreview layout by changing the <KeyboardView> attribute android:keyPreviewLayout. This is styled by default to look at keyboard_key_preview.xml:

Edit 2: Following my be a red herring:

The source code suggests supplying 0 or not applying the tag android:keyPreviewLayout will result in no key preview appearing:

    ...
    case com.android.internal.R.styleable.KeyboardView_keyPreviewLayout:
        previewLayout = a.getResourceId(attr, 0);
        break; 
    ...
    if (previewLayout != 0) {
        mPreviewText = (TextView) inflate.inflate(previewLayout, null);
        mPreviewTextSizeLarge = (int) mPreviewText.getTextSize();
        mPreviewPopup.setContentView(mPreviewText);
        mPreviewPopup.setBackgroundDrawable(null);
    } else {
        mShowPreview = false;
    }  

I've tried:

  • A styled KeyboardView with no keyPreviewLayout (Strangely though replacing this value changed the style of the preview.)
  • I made a keyPreviewLayout reference an id with a value of 0 (which causes a crash on inflation).

Stumped. :( Any help would be greatly appreciated!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There's a method:

public void setPreviewEnabled(boolean previewEnabled)

But I don't know which version of the API that starts at.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...