Skip to content Skip to sidebar Skip to footer

Android Custom Keyboard Popup Keyboard On Long Press

I have custom Android keyboard: public class CustomKeyboard extends Keyboard{...} public class CustomKeyboardView extends KeyboardView{...} public class CustomKeybo

Solution 1:

You can use PopupWindow class and populate it with custom layout.

View custom = LayoutInflater.from(context)
    .inflate(R.layout.your_layout, new FrameLayout(context));
PopupWindow popup = new PopupWindow(context);
popup.setContentView(custom);

and on long press

//Get x,y based on the touch position//Get width, height based on your layoutif(popup.isShowing()){
    popup.update(x, y, width, height);
} else {
    popup.setWidth(width);
    popup.setHeight(height);
    popup.showAtLocation(yourKeyboardView, Gravity.NO_GRAVITY, x, y);
}

On click in the popup you can dismiss it

popup.dismiss();

Post a Comment for "Android Custom Keyboard Popup Keyboard On Long Press"