To implement the top-level window pop-up in Android, it is usually implemented with Windowsmanager, but almost all of the site resources are said to pop up the hover window without accepting any key response.
The problem is that we sometimes need him to respond to keystrokes such as Android on TV, we want it to respond to the volume buttons on the remote control, and so on. At this point, the added view must be layoutparams related settings.
The main code is two places.
First, the added view cannot be set layoutparams.flags=layoutparams.flag_not_focusable;//otherwise it completely shields the button.
Second, you need to set View.setfocusableintouchmode (true);
After these two settings, for the added view set the key to listen to receive the key information, how to deal with is to see the demand.
View.setonkeylistener (new Onkeylistener () { @Override publicBoolean int KeyCode, KeyEvent event) { log.e ("wytings", "Onkeylistener"); return false ; } });
About the Android hover window to get key response questions