Create an Android pop-up keyboard

I followed examples on developer.android.com regarding input methods and played with the SoftKeyboard sample application. Together, they provide more than enough information about creating a simple keyboard.

I created a 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 a question about a popup.

  • I want to show a keyboard popup. but a popup appears next to the pressed key. is there any idea of ​​showing a popup in the center of the keyboard?

  • a long press of a key displays a popup window. I want to show a popup when short printing. I have an idea?

If anyone knows a solution, please help me.

+4
1

, , . , Dialog PopupWindow, PopupWindow .

, onLongPress onTouchEvent, onTouchEvent, , popupWindow.

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);

x y .

0

All Articles