I am currently working on my own implementation of Input Method Editor (IME) or can be called as Soft keyboard in Android, I have read creating an input method and I have downloaded the Soft Keyboard sample code provided as part of the SDK, now I want to know how to make this highlight as showing in below image ,when I press any key of the keyboard. any one can tell me how to do that??
Asked
Active
Viewed 1,115 times
2
-
1I'm newbie I do not have any idea, so please can you suggest me in that `Sample Code ` where can I find that and make some changes. – Feb 14 '14 at 13:24
-
Here is a topic that explains what you want to do : http://stackoverflow.com/questions/7752580/creating-a-softkeyboard-with-multiple-alternate-characters-per-key – kmas Feb 14 '14 at 14:05
-
@kmas I have tried that but am not able to get the job done please can you code for only one key so that I can get hint and make my way clear.. plz – Feb 14 '14 at 17:48
1 Answers
1
I have tried to answer the question and I have made a significant effort, but this is not the perfect answer, I have came up with following
Step-1 create custom_preview.xml
file in drawable
folder write some thing like:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="5dp"
android:shape="rectangle" >
<solid android:color="#436EEE" />
<corners android:radius="4dp" />
</shape>
Step-2 create popup_prewview_layout.xml
file in layout
folder write this:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:background="@drawable/custom_preview"
android:gravity="center"
android:textColor="@android:color/white"
android:textSize="32sp" />
Step-3 now in main_layout.xml
add android:keyPreviewLayout="@layout/popup_preview_layout"
, like this :
<?xml version="1.0" encoding="utf-8"?>
<com.example.keyboard.KeyboardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#FF272727"
android:keyPreviewLayout="@layout/keyboard_popup_preview"/>
RESULT
OK so that was effort, but not the perfect solution for you, because there is not any triangle
at the bottom of preview. that maybe an other question. Hope this is some thing working for you...

Arshad Ali
- 3,082
- 12
- 56
- 99
-
first of all `Thanks` for this guide, but how can I make that triangle shape at the bottom of that preview as well please... – Feb 15 '14 at 05:50