交换应用内的键盘时,Android在我的自定义键盘下方显示白屏

时间:2018-09-13 09:57:29

标签: android-input-method android-custom-keyboard

我有一个专用键盘,专门用于玩基于文本的游戏。问题是,当我将键盘从主键盘(键盘)更改为其他键盘(旅行键盘)时,白色屏幕掩盖了键盘底部的一小部分,并且一直存在,直到我重新启动键盘为止。如果我不切换到旅行键盘,没问题。 仅在LG Stylo 4 android OREO设备中发现该问题。

我的主键盘xml:keyboard = new Keyboard(this, R.xml.drpgkey);

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyHeight="9%p"
android:keyWidth="10%p"
android:verticalGap="0.55%p">

<Row>
    <Key
        android:codes="888"
        android:keyEdgeFlags="left"
        android:keyHeight="27%p"
        android:keyLabel="ADV"
        android:keyWidth="40%p" />

    <Key
        android:codes="907"
        android:horizontalGap="1%p"
        android:keyLabel="MINE"
        android:keyWidth="29%p" />
    <Key
        android:codes="905"
        android:horizontalGap="1%p"
        android:keyEdgeFlags="right"
        android:keyLabel="CHOP"
        android:keyWidth="29%p" />
</Row>

<Row>
    <Key
        android:codes="906"
        android:horizontalGap="41%p"
        android:keyLabel="FORAGE"
        android:keyWidth="29%p" />
    <Key
        android:codes="908"
        android:horizontalGap="1%p"
        android:keyEdgeFlags="right"
        android:keyLabel="FISH"
        android:keyWidth="29%p" />
</Row>

<Row
    android:keyHeight="8%p"
    android:keyboardMode="@integer/default_keys">
    <Key
        android:codes="201"
        android:horizontalGap="41%p"
        android:keyLabel="O.o"
        android:keyWidth="11%p"
        android:popupKeyboard="@xml/inv" />
    <Key
        android:codes="334"
        android:horizontalGap="1%p"
        android:keyLabel="Undefined"
        android:keyWidth="35%p"
        android:popupKeyboard="@xml/market" />
    <Key
        android:codes="202"
        android:horizontalGap="1%p"
        android:keyEdgeFlags="right"
        android:keyLabel="o.O"
        android:keyWidth="11%p"
        android:popupKeyboard="@xml/ginv" />
</Row>

<Row
    android:keyHeight="8%p"
    android:keyboardMode="@integer/custom_keys">
    <Key
        android:codes="201"
        android:horizontalGap="41%p"
        android:keyLabel="O_o"
        android:keyWidth="11%p"
        android:popupKeyboard="@xml/customkeys_left" />
    <Key
        android:codes="334"
        android:horizontalGap="1%p"
        android:keyLabel="Undefined"
        android:keyWidth="35%p"
        android:popupKeyboard="@xml/market" />
    <Key
        android:codes="202"
        android:horizontalGap="1%p"
        android:keyEdgeFlags="right"
        android:keyLabel="o_O"
        android:keyWidth="11%p"
        android:popupKeyboard="@xml/customkeys_right" />
</Row>

<Row
    android:keyHeight="8%p"
    android:rowEdgeFlags="bottom">
    <Key
        android:codes="900"
        android:keyEdgeFlags="left"
        android:keyLabel="STATS"
        android:keyWidth="19.20%p"
        android:popupKeyboard="@xml/stats" />
    <Key
        android:codes="901"
        android:keyLabel="PET"
        android:horizontalGap="1%p"
        android:keyWidth="19.20%p" />
    <Key
        android:codes="903"
        android:keyLabel="HEAL"
        android:horizontalGap="1%p"
        android:keyWidth="19.20%p" />
    <Key
        android:codes="904"
        android:keyLabel="PHEAL"
        android:horizontalGap="1%p"
        android:keyWidth="19.20%p" />
    <Key
        android:codes="333"
        android:keyEdgeFlags="right"
        android:keyIcon="@drawable/key_icon"
        android:horizontalGap="1%p"
        android:keyWidth="19.20%p"
        android:popupKeyboard="@xml/optionkey" />
</Row>

我的旅行键盘:travelkeyboard = new Keyboard(this, R.xml.travelkeys);

<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyHeight="9%p"
android:horizontalGap="1%p"
android:keyWidth="28%p"
android:verticalGap="0.55%p">

<Row>
    <Key
        android:codes="701"
        android:keyLabel=""
        android:keyEdgeFlags="left" />
    <Key
        android:codes="702"
        android:keyLabel="" />
    <Key
        android:codes="703"
        android:keyLabel="" />
    <Key
        android:codes="335"
        android:keyEdgeFlags="right"
        android:keyIcon="@drawable/ic_return"
        android:keyWidth="13%p" />
</Row>
<Row>
    <Key
        android:codes="704"
        android:keyLabel=""
        android:keyEdgeFlags="left" />
    <Key
        android:codes="700"
        android:keyIcon="@drawable/ic_location"
        android:popupKeyboard="@xml/tags" />
    <Key
        android:codes="705"
        android:keyLabel="" />
    <Key
        android:codes="909"
        android:keyEdgeFlags="right"
        android:keyIcon="@drawable/ic_search"
        android:keyWidth="13%p" />
</Row>
<Row>
    <Key
        android:codes="706"
        android:keyLabel=""
        android:keyEdgeFlags="left" />
    <Key
        android:codes="707"
        android:keyLabel="" />
    <Key
        android:codes="708"
        android:keyLabel="" />
    <Key
        android:codes="699"
        android:keyEdgeFlags="right"
        android:keyIcon="@drawable/ic_map"
        android:keyWidth="13%p"
        android:popupKeyboard="@xml/runes" />
</Row>
<Row
    android:keyHeight="7%p"
    android:keyWidth="24.25%p"
    android:rowEdgeFlags="bottom">
    <Key
        android:codes="711"
        android:keyEdgeFlags="left"
        android:keyIcon="@drawable/ic_notalk"
        android:popupKeyboard="@xml/task" />
    <Key
        android:codes="712"
        android:keyIcon="@drawable/ic_notalk" />
    <Key
        android:codes="713"
        android:isRepeatable="true"
        android:keyIcon="@drawable/ic_notalk" />
    <Key
        android:codes="714"
        android:keyEdgeFlags="right"
        android:keyIcon="@drawable/ic_notalk" />
</Row>
</Keyboard>

然后我用一个键(主要代码)交换键盘

        case 334:          
            kv.setKeyboard(travelkeyboard);
            break;
        case 335:
            kv.setKeyboard(keyboard);
            break;

图片:https://imgur.com/a/2WOHtOp

发现该问题仅在LG Stylo 4设备上。

0 个答案:

没有答案