I have created custom keyboard using buttons within LinearLayout and I handle the click event from xml attribute - android:onClick. In onCreateInputView method I used LayoutInfalte, and it is working perfectly. But now I want add key preview on click it. Is is possible to use PopupWindow in InputMethodService?
String text = pressedButton.getText().toString();
View layout = getLayoutInflate.Inflater(R.layout.key_preview);
TextView tvPreview = layout.findViewById(R.id.tv_keypr_eview);
tvPreview.setText(text);
PopupWindow preview = new PopupWindow(layout);
preview.setWidth = pressedButton.getWidth() + 2;
preview.setHeight = pressedButton.getHeight() + 2;
int x = (int)pressedButton.getX - 4;
int y = (int)pressedButton.getY - 4;
preview.showAtLocation(pressedButton, Gravity.NO_GRAVITY, x, y);
}
```
But showing nothing and keyboard is hiding after pressing key.