customize soft keyboard key preview

丶灬走出姿态 提交于 2019-12-10 11:39:18

问题


I am working on soft keyboard. I had done with all of my functionality.

But now i just need to change view of key preview when key is pressed. Currently my key preview is shown(default sample keyboard key preview) like shown in below image,

As we can see character 'd' is popped up when key is pressed.

But now i need customize it. As currently key preview background is white, i need it to set green color just like shown below,

I have the sample keyboard code, but couldn't find the place where it show a popout letter. So i can easily edit it customize it my own way.

I googled for help nothing found any help any. Any help is appreciated.


回答1:


Use something like this in your keys XML layout:

<Key android:codes="97" android:keyIcon="@drawable/key_icon" android:iconPreview="@drawable/key_preview_icon" /> 

It worked for me. I hope this helps you :)




回答2:


You may have created a android.inputmethodservice.KeyboardView.xml layout resource file

Use android:keyBackground="#FF419F3C"

<?xml version="1.0" encoding="utf-8"?>
<android.inputmethodservice.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    android:id="@+id/keyboard"
    android:labelTextSize="20dp"
    android:background="@color/colorTrybg"        
    android:keyTextColor="@color/colorTrykey"
              <!-- This one -->
    android:keyBackground="#FFFFFF"
    android:layout_alignParentBottom="true"
    android:keyPreviewLayout="@layout/preview">
</android.inputmethodservice.KeyboardView>


来源:https://stackoverflow.com/questions/20299210/customize-soft-keyboard-key-preview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!