4

I've followed the examples on developer.android.com regarding Input Methods and played with the SoftKeyboard sample application. These together give more than enough information regarding the creation of simple keyboard.

I made popup keyboard using "android:popupKeyboard".

<Row android:keyHeight="@dimen/key_height"
    android:id="@+id/label"
>
    <Key android:codes="97" android:keyLabel="a" android:horizontalGap="@dimen/horizontal_border_gap" 
            android:keyEdgeFlags="left" android:keyBackground="@drawable/key_btn_l" android:popupKeyboard="@xml/popup"/>
    <Key android:codes="115" android:keyLabel="s" android:keyBackground="@drawable/key_btn_l"/>
    <Key android:codes="100" android:keyLabel="d" android:keyBackground="@drawable/key_btn_l"/>
    <Key android:codes="102" android:keyLabel="f" android:keyBackground="@drawable/key_btn_a"/>
    <Key android:codes="103" android:keyLabel="g" android:keyBackground="@drawable/key_btn_l" android:popupKeyboard="@xml/popup"/>
    <Key android:codes="104" android:keyLabel="h" android:keyBackground="@drawable/key_btn_a"/>
    <Key android:codes="106" android:keyLabel="j" android:keyBackground="@drawable/key_btn_a"/>
    <Key android:codes="107" android:keyLabel="k" android:keyBackground="@drawable/key_btn_a"/>
    <Key android:codes="108" android:keyLabel="l" android:keyBackground="@drawable/key_btn_l"/>
    <Key android:codes="45" android:keyLabel="-" android:keyEdgeFlags="right" android:keyBackground="@drawable/key_btn_a"/>
</Row>

I have question about popup.

  1. I wish show popup center of keyboard. but popup is shown near pressed key. is there any idea for showing popup at center of keyboard?

  2. when long press the key, the popup is shown. I wish show popup when short press. there is any idea?

If anyone knows solution, please help me.

Jungoo
  • 41
  • 3
  • you follow :http://stackoverflow.com/questions/29390175/android-custom-keyboard-popup-keyboard-on-long-press http://stackoverflow.com/questions/3514392/android-ime-showing-a-custom-pop-up-dialog-like-swype-keyboard-which-can-ente/6166857#6166857 and http://stackoverflow.com/questions/5684076/how-do-i-make-a-view-float-above-other-views-in-an-ime – Sonu Kumar Sep 16 '15 at 06:04
  • I thing this link helps you http://stackoverflow.com/questions/7752580/creating-a-softkeyboard-with-multiple-alternate-characters-per-key – saeed Oct 15 '15 at 10:30

1 Answers1

0

The default popup is low customizable, but you can create your own popup for your keyboard and customize all that you want. I think you can do this with Dialog and PopupWindow, but PopupWindow is the best in this case.

Create your own keyboardView, then you can use a method like onLongPress, or onTouchEvent, if use onTouchEvent you can count the time the key is pressed and then show your popupWindow.

To create popupWindow:

View view = LayoutInflater.from(context)
        .inflate(R.layout.popup_layout, new FrameLayout(context));
popup = new PopupWindow(context);
popup.setContentView(view);
popup.setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
popup.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
popup.showAtLocation(this, Gravity.CENTER, x, y);

Create variables for x and y and get based on the touch position.

Ricardo A.
  • 685
  • 2
  • 8
  • 35