简体   繁体   English

如何禁用弹出键盘中的按键预览(不在主软键盘布局中)?

[英]How to disable key preview in popup keyboard (not in main softkeyboard layout)?

It's easy to disable key previews: just call setPreviewEnabled(false) and these annoying tiny previews won't show up anymore.禁用按键预览很容易:只需调用 setPreviewEnabled(false),这些烦人的小预览将不再出现。 But if I attach a popup keyboard to any key then these previews will show up inside that popup:但是,如果我将弹出式键盘附加到任何键,那么这些预览将显示在该弹出式窗口中:

qwerty.xml: qwerty.xml:

<Key android:codes="101" 
    android:keyLabel="E" 
    android:popupKeyboard="@xml/popup"
   android:keyTextSize="60sp"/>

popup.xml:弹出窗口.xml:

<Row>
    <Key android:codes="-10000"
        android:keyLabel="test"
        android:keyOutputText="test"/>
</Row>
<Row>
    <Key android:codes="-10001"
        android:keyLabel="test2"
        android:keyOutputText="test2"/>
</Row>

Can't post images, but if I long press letter 'E' and then press test or test2 button they will show that white key preview.无法发布图像,但如果我长按字母“E”,然后按 test 或 test2 按钮,它们将显示白键预览。

Is there any way to disable these key previews too?有什么办法也可以禁用这些关键预览吗?

set this in your popup layout set this attribute:在您的弹出式布局中设置此属性:

android:keyPreviewLayout="0"

or或者

android:keyPreviewLayout="@null"

Call setPreviewEnabled(false) for the popup keyboard view too也为弹出式键盘视图调用setPreviewEnabled(false)

// Find popup keyboard by its view-id
pKeyboardView
android.inputmethodservice.KeyboardView = (KeyboardView)mHostActivity.findViewById(viewid);

// Disable key-previews for the popup keyboard too
pKeyboardView.setPreviewEnabled(false); 

create a CustomKeyboard with setPreviewEnabled(false) add your rows inside CustomeKeyboard in popup.xml as below创建一个带有 setPreviewEnabled(false) 的 CustomKeyboard 在 popup.xml 中的 CustomeKeyboard 中添加您的行,如下所示

<CustomKeyboard 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:keyWidth="10%p"
        android:horizontalGap="0px"
        android:verticalGap="0px"
        android:keyHeight="60px" >
        <Row><Key android:codes="-10000"
            android:keyLabel="test"
            android:keyOutputText="test"/> </Row> 
        <Row><Key android:codes="-10001"
            android:keyLabel="test2"
            android:keyOutputText="test2"/></Row>
</CustomKeyboard>

In your keyboardView set a layout for your popup with在您的键盘视图中为您的弹出窗口设置布局

android:popupLayout=""

And in your popup layout set this attribute:并在您的弹出式布局中设置此属性:

android:keyPreviewLayout="@null"

1) Your need to set your popupLayout your current popup layout is this 1) 您需要设置您的 popupLayout 您当前的弹出式布局是这样的

2) inside your popupLayout set android:keyPreviewLayout="@null" this will hide your preview inside popup 2) 在您的 popupLayout 设置 android:keyPreviewLayout="@null" 这将隐藏您在弹出窗口中的预览

for more description check更多描述检查

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

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