Can I display PopupWindow from InputMethodService in android?

14 Views Asked by At

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.
  
0

There are 0 best solutions below