2017-09-18 325 views
4

我正嘗試在android中爲替代鍵創建自定義彈出式鍵盤。通過使用默認的鍵盤唯一定製,我可以做的是爲彈出式鍵盤提供自定義佈局。爲替代鍵創建自定義彈出式鍵盤

我需要定製行爲,以及(如一個在Gboard)比如,

(1)當按鈕被長按,默認情況下它應該突出一個特定的密鑰

(2)鍵可以通過移動手指被高亮顯示,並且還選擇(長按鍵和移動手指同時)

這些是我所引用的鏈接:

Building a custom android keyboard

Creating a SoftKeyboard with Multiple/Alternate characters per key

How do you disable the SoftKeyboard key preview window?

這是彈出式鍵盤Gboard enter image description here

任何建議/幫助將不勝感激。

謝謝。

+0

您是否找到任何解決方案? –

+0

@MateenChaudhry沒有 – chathura

+0

你在鍵盤上實現了建議嗎? –

回答

1
<?xml version="1.0" encoding="utf-8"?> 


    <Keyboard xmlns:android="http://schemas.android.com/apk/res/android" 
     android:keyWidth="10%p" 
     android:horizontalGap="0px" 
     android:verticalGap="0px" 
     android:keyHeight="@dimen/key_height"> 
     <Row android:keyHeight="2px"></Row> 
     <Row> 
      <Key 
       android:codes="49" 
       android:keyEdgeFlags="left" 
       android:keyLabel="1" /> 
      <Key 
       android:codes="50" 
       android:keyLabel="2" /> 
      <Key 
       android:codes="51" 
       android:keyLabel="3" /> 
      <Key 
       android:codes="52" 
       android:keyLabel="4" /> 
      <Key 
       android:codes="53" 
       android:keyLabel="5" /> 
      <Key 
       android:codes="54" 
       android:keyLabel="6" /> 
      <Key 
       android:codes="55" 
       android:keyLabel="7" /> 
      <Key 
       android:codes="56" 
       android:keyLabel="8" /> 
      <Key 
       android:codes="57" 
       android:keyLabel="9" /> 
      <Key 
       android:codes="48" 
       android:keyEdgeFlags="right" 
       android:keyLabel="0" /> 
     </Row> 

     <Row> 
      <Key 
       android:codes="113" 
       android:keyEdgeFlags="left" 
       android:keyLabel="q" /> 
      <Key 
       android:codes="119" 
       android:keyLabel="w" /> 

      <Key 
       android:codes="101" 
       android:keyLabel="e" /> 
      <Key 
       android:codes="114" 
       android:keyLabel="r" /> 
      <Key 
       android:codes="116" 
       android:keyLabel="t" /> 
      <Key 
       android:codes="121" 
       android:keyLabel="y" /> 
      <Key 
       android:codes="117" 
       android:keyLabel="u" /> 
      <Key 
       android:codes="105" 
       android:keyLabel="i" /> 

      <Key 
       android:codes="111" 
       android:keyLabel="o" /> 
      <Key 
       android:codes="112" 
       android:keyEdgeFlags="right" 
       android:keyLabel="p" /> 
     </Row> 


     <Row> 

      <Key 
       android:codes="97" android:keyLabel="a" android:horizontalGap="5%p" 
       android:keyEdgeFlags="left" android:popupKeyboard="@xml/keyboard_popup_template" 
       android:popupCharacters="áăä"/> 
      <Key 
       android:codes="115" 
       android:keyLabel="s" /> 
      <Key 
       android:codes="100" 
       android:keyLabel="d" /> 
      <Key 
       android:codes="102" 
       android:keyLabel="f" /> 
      <Key 
       android:codes="103" 
       android:keyLabel="g" /> 
      <Key 
       android:codes="104" 
       android:keyLabel="h" /> 
      <Key 
       android:codes="106" 
       android:keyLabel="j" /> 
      <Key 
       android:codes="107" 
       android:keyLabel="k" /> 
      <Key 
       android:codes="108" 
       android:keyEdgeFlags="right" 
       android:keyLabel="l" /> 


     </Row> 

     <Row> 
      <Key 
       android:codes="-1" android:keyIcon="@drawable/narrow2" 
       android:keyWidth="15%p" android:isModifier="true" 
       android:isSticky="true" android:keyEdgeFlags="left" /> 
      <Key 
       android:codes="122" 
       android:keyLabel="z" 
       android:keyWidth="15%p" /> 
      <Key 
       android:codes="120" 
       android:keyLabel="x" 
       android:keyWidth="15%p" /> 
      <Key 
       android:codes="99" 
       android:keyLabel="c" 
       android:keyWidth="15%p" /> 
      <Key 
       android:codes="118" 
       android:keyLabel="v" 
       android:keyWidth="15%p" /> 
      <Key 
       android:codes="98" 
       android:keyLabel="b" 
       android:keyWidth="15%p" /> 
      <Key 
       android:codes="110" 
       android:keyLabel="n" 
       android:keyWidth="15%p" /> 
      <Key 
       android:codes="109" 
       android:keyLabel="m" 
       android:keyWidth="15%p" /> 
      <Key 
       android:codes="-5" 
       android:isRepeatable="true" 
       android:keyEdgeFlags="right" 
       android:keyIcon="@drawable/sym_keyboard_delete" 
       android:keyWidth="20%p" /> 
     </Row> 

     <Row 
      android:rowEdgeFlags="bottom" 
      android:verticalGap="5px"> 

      <Key 
       android:codes="-2" 
       android:keyEdgeFlags="left" 
       android:keyLabel="123" 
       android:keyWidth="15%p" /> 
      <Key 
       android:codes="64" 
       android:keyLabel="\@" 
       android:keyWidth="10%p" /> 

      <Key 
       android:codes="-101" 
       android:keyIcon="@drawable/sym_keyboard_language_switch" 
       android:keyWidth="10%p" /> 
      <Key 
       android:codes="32" 
       android:isRepeatable="true" 
       android:keyLabel="SPACE" 
       android:keyWidth="30%p" /> 

      <Key 
       android:codes="46" 
       android:keyLabel="." 
       android:keyWidth="10%p" /> 
      <Key 
       android:codes="44" 
       android:keyLabel="," 
       android:keyWidth="10%p" 
       android:popupCharacters=".,?!#@" 
       android:popupKeyboard="@xml/keyboard_popup_template" /> 
      <Key 
       android:codes="-4" 
       android:keyEdgeFlags="right" 
       android:keyLabel="DONE" 
       android:keyWidth="20%p" /> 
     </Row> 

     <Row android:keyHeight="2px"></Row> 

    </Keyboard> 

Please try it. 
+0

這不是他詢問自定義彈出窗口的問題的答案 –