android 原生输入法修改适配无TP设备实战

初衷

由于项目需求,当前的设备没有TP,因此系统默认软键盘输入法无法点击输入,考虑0费用下,我将android原生的Soft Keyboard输入法进行了改造,让其可以通过物理按键获取到焦点,从而进行按键输入。

下面是本次修改所作出的全部patch,请参考。

diff --git a/samples/SoftKeyboard/res/xml/qwerty.xml b/samples/SoftKeyboard/res/xml/qwerty.xml
index 936c977..568a4c4 100755
--- a/samples/SoftKeyboard/res/xml/qwerty.xml
+++ b/samples/SoftKeyboard/res/xml/qwerty.xml
@@ -70,17 +70,18 @@
     <Row android:rowEdgeFlags="bottom">
         <Key android:codes="-3" android:keyIcon="@drawable/sym_keyboard_done" 
                 android:keyWidth="15%p" android:keyEdgeFlags="left"/>
-        <Key android:codes="-2" android:keyLabel="123" android:keyWidth="10%p"/>
+        <Key android:codes="-2" android:keyLabel="123" android:keyWidth="15%p"/>
         <!--
             android:codes: -101 is not a framework-defined key code but a key code that is
             privately defined in com.example.android.softkeyboard.LatinKeyboardView.
-        -->
+
         <Key android:codes="-101" android:keyIcon="@drawable/sym_keyboard_language_switch"
                 android:keyWidth="10%p"/>
+        -->
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" 
                 android:keyWidth="30%p" android:isRepeatable="true"/>
         <Key android:codes="46,44" android:keyLabel=". ,"
-                android:keyWidth="15%p"/>
+                android:keyWidth="20%p"/>
         <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return" 
                 android:keyWidth="20%p" android:keyEdgeFlags="right"/>
     </Row>
diff --git a/samples/SoftKeyboard/res/xml/symbols.xml b/samples/SoftKeyboard/res/xml/symbols.xml
index 225ea08..23848d6 100755
--- a/samples/SoftKeyboard/res/xml/symbols.xml
+++ b/samples/SoftKeyboard/res/xml/symbols.xml
@@ -70,16 +70,17 @@
     <Row  android:rowEdgeFlags="bottom">
         <Key android:codes="-3" android:keyIcon="@drawable/sym_keyboard_done"
                 android:keyWidth="15%p" android:keyEdgeFlags="left" />
-        <Key android:codes="-2" android:keyLabel="ABC" android:keyWidth="10%p" />
+        <Key android:codes="-2" android:keyLabel="ABC" android:keyWidth="15%p" />
         <!--
             android:codes: -101 is not a framework-defined key code but a key code that is
             privately defined in com.example.android.softkeyboard.LatinKeyboardView.
-        -->
+
         <Key android:codes="-101" android:keyIcon="@drawable/sym_keyboard_language_switch"
                 android:keyWidth="10%p" />
+        -->
         <Key android:codes="32" android:keyIcon="@drawable/sym_keyboard_space" android:keyWidth="30%p" 
                 android:isRepeatable="true"/>
-        <Key android:codes="44" android:keyLabel="," android:keyWidth="15%p" />
+        <Key android:codes="44" android:keyLabel="," android:keyWidth="20%p" />
         <Key android:codes="10" android:keyIcon="@drawable/sym_keyboard_return"
                 android:keyWidth="20%p" android:keyEdgeFlags="right"
                 />
diff --git a/samples/SoftKeyboard/res/xml/symbols_shift.xml b/samples/SoftKeyboard/res/xml/symbols_shift.xml
index fa551f2..c3ea4f1 100755
--- a/samples/SoftKeyboard/res/xml/symbols_shift.xml
+++ b/samples/SoftKeyboard/res/xml/symbols_shift.xml
@@ -70,16 +70,17 @@
     <Row android:rowEdgeFlags="bottom">
         <Key android:codes="-3" android:keyIcon="@drawable/sym_keyboard_done" 
                 android:keyWidth="15%p" android:keyEdgeFlags="left" />
-        <Key android:codes="-2" android:keyLabel="ABC" android:keyWidth="10%p" />
+        <Key android:codes="-2" android:keyLabel="ABC" android:keyWidth="15%p" />
         <!--
             android:codes: -101 is not a framework-defined key code but a key code that is
             privately defined in com.example.android.softkeyboard.LatinKeyboardView.
-        -->
+
         <Key android:codes="-101" android:keyIcon="@drawable/sym_keyboard_language_switch
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值