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

问题描述 投票:24回答:5

禁用关键预览很容易:只需调用setPreviewEnabled(false),这些烦人的微小预览将不再显示。但是,如果我将弹出式键盘附加到任何键,则这些预览将显示在该弹出式窗口中:

qwerty.xml:

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

popup.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>

无法发布图像,但是如果我长按字母'E',然后按test或test2按钮,它们将显示该白键预览。

也有什么方法可以禁用这些关键预览吗?

android android-softkeyboard custom-keyboard keypreview
5个回答
4
投票

在您的弹出式布局中设置此设置此属性:

android:keyPreviewLayout="0"

android:keyPreviewLayout="@null"

3
投票

也为弹出键盘视图调用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); 

3
投票

使用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>

1
投票

在您的keyboardView中为您的弹出式窗口设置布局

android:popupLayout=""

并且在您的弹出布局中设置此属性:

android:keyPreviewLayout="@null"

0
投票

1)您需要设置popupLayout您当前的弹出布局是this

2)在您的popupLayout中设置了android:keyPreviewLayout =“ @ null”,这会将您的预览隐藏在弹出窗口中

有关更多说明check

© www.soinside.com 2019 - 2024. All rights reserved.