【问题标题】:How to disable key preview in popup keyboard (not in main softkeyboard layout)?如何禁用弹出键盘中的键预览(不在主软键盘布局中)?
【发布时间】:2015-08-25 17:53:15
【问题描述】:

禁用按键预览很容易:只需调用 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”,然后按测试或 test2 按钮,它们将显示白键预览。

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

【问题讨论】:

  • 屏幕截图或模拟图片将有助于更好地理解问题。
  • @AndroidMechanic 给你:pasteboard.co/1gjEd5Ye.jpg 当我长按弹出键盘时出现了这个白色方块..
  • 你能发布你的keyboardView吗?

标签: android android-softkeyboard custom-keyboard keypreview


【解决方案1】:

在你的弹出布局中设置这个属性:

android:keyPreviewLayout="0"

或

android:keyPreviewLayout="@null"

【讨论】:

    【解决方案2】:

    也可以调用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>
    

    【讨论】:

      【解决方案4】:

      在你的keyboardView中为你的弹出窗口设置一个布局

      android:popupLayout=""
      

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

      android:keyPreviewLayout="@null"
      

      【讨论】:

        【解决方案5】:

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

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

        更多描述check

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-04-20
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多