2016-12-30 99 views
2

我想实现扩展键盘(输入法)。
我不知道是否有我可以包装的一个defualt键盘资源/实现。例如,如果用户按'默认kbd'块'qwerty'显示为默认的Android键盘,并且我按'我的扩展名'块qwerty替换为扩展名。 注:我寻找的方式(如果存在)不rebuilnd defualt键盘来创建自定义输入法,而不是程序只键盘盖这样https://github.com/chiragjain/Emoticons-Keyboard是否有可能包装默认的Android键盘

enter image description here

回答

0

你必须创建自己的自定义键盘显示这样的情况。在您的键盘上,您可以一次保持两个不同的图层。因此,所有你需要的是KeyboardView类:

<android.inputmethodservice.KeyboardView 
    android:id="@+id/keyboardView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:focusable="true" 
    android:focusableInTouchMode="true" 
    android:visibility="gone" 
    android:keyBackground="@color/background_color" 
    android:keyTextColor="#37474F" 
    android:keyTextSize="20sp" 
    android:fontFamily="sans-serif" 
    android:background="#ECEFF1"/> 

资源遵循:

https://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615

http://www.fampennings.nl/maarten/android/09keyboard/index.htm

虽然这些例子只会在关键的表示显示例如,你可以轻松地添加任何XML作为键盘层。

3

你试图不幸做什么不可能。

试图找到一个开源的键盘实现,并建立它。 请参见this GitHub repository以获取默认LatinIME的工作实现,并将其用作基础。

0

你可以尝试下招:

  1. 检测键盘的瞬间被显示。
  2. 评估布局的底部。
  3. 在键盘上方显示您的用户界面。
  4. 隐藏你的用户界面的时刻,键盘隐藏。

根据键盘显示模式(adjustResiz或adjustPan),“2”和“3”会略有不同。

有用的链接: