Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make sure a window always showing above soft keyboard?

I add a view by WindowManager above soft keyboard with TYPE_APPLICATION_PANEL, but it doesn't work on some phones, neither TYPE_SYSTEM_ALERT. What should I do to make it happen on all phones?

like image 534
handrenliang Avatar asked Jul 07 '15 10:07

handrenliang


1 Answers

TYPE_SYSTEM_ALERT windows do not work on some devices at all, but if they work they should be placed above the IME window. I would recommend you to try TYPE_TOAST windows. Toasts work on all devices and are shown above keyboard. But on some Android versions like 4.1 toasts do not accept user input such as touches or key events.

TYPE_PHONE might also be a good candidate for solving your problem but I think it will not work on devices where TYPE_SYSTEM_ALERT doesn't work.

UPDATE: Another thing you may try is to add WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM to WindowManager.LayoutParams.flags. This flag tells Android to position a window so that it can cover IME. In this case WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE flag must be unset. In this configuration the window will be focusable and should be positioned in front of IME.

Another option is to have just WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE flag set and WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM flag unset. It will also make your window positioned in front of IME but the window will not be focusable.

like image 54
Michael Avatar answered Sep 22 '22 13:09

Michael