简体   繁体   中英

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. But if I attach a popup keyboard to any key then these previews will show up inside that popup:

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>

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.

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

// 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

<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

2) inside your popupLayout set android:keyPreviewLayout="@null" this will hide your preview inside popup

for more description check

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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