[英]How to disable key preview in popup keyboard (not in main softkeyboard layout)?
禁用按鍵預覽很容易:只需調用 setPreviewEnabled(false),這些煩人的小預覽將不再出現。 但是,如果我將彈出式鍵盤附加到任何鍵,那么這些預覽將顯示在該彈出式窗口中:
qwerty.xml:
<Key android:codes="101"
android:keyLabel="E"
android:popupKeyboard="@xml/popup"
android:keyTextSize="60sp"/>
彈出窗口.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:keyPreviewLayout="0"
或者
android:keyPreviewLayout="@null"
也為彈出式鍵盤視圖調用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);
創建一個帶有 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>
在您的鍵盤視圖中為您的彈出窗口設置布局
android:popupLayout=""
並在您的彈出式布局中設置此屬性:
android:keyPreviewLayout="@null"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.