About the Android hover window to get key response questions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.