I'm developing a soft keyboard for Android (respectively I'm trying ;)) and since I'm new to Android and Java it's not that easy. The basic keyboard is working (thanks to examples in the web) and now 开发者_JS百科I'm trying to create a sort of "popup" (with new buttons) which is evoked when you press and hold a button for a certain time (time should be open for customization). Then one should be able to drag the finger to the new buttons. For example: You hold e and then drag the finger to é etc.
My first attempt was to use something like:
<Key android:codes="101" android:keyLabel="e"
android:popupKeyboard="@layout/popup"
android:popupCharacters="eéè€"
/>
where popup.xml contains a seperate basic keyboard structure:
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:keyWidth="10%p"
android:horizontalGap="0px"
android:verticalGap="0px"
android:keyHeight="30px" />
But there are several disadvantages:
- I don't know how to tweak the position and appearance of the popup
- the finger has to be lifted in order to press a new button (weird behaviour)
- the time the user has to wait until the popup appears seems to be fixed
How would you solve this problem? An invisible key-row (absolute position) which is set to visible once a button is touched for a certain time (monitored with motion events etc.) ? Do you know any tutorials which give information on this "press-hold-drag-button"-concept in keyboards? A code example would be very helpful. I looked through the LatinIME git project but unfortunately it's very overwhelming :/
This is a very, very old question, but this may help someone else like me. I am browsing the Android source code to see how to make the alt-key popup: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/inputmethodservice/KeyboardView.java#KeyboardView.onLongPress%28android.inputmethodservice.Keyboard.Key%29
精彩评论