WindowManager没有获取到焦点

今天遇到一个问题,WindowManager同时add两个view,后出来的view上面的按钮虽然通过requestFocus方法拿到了焦点,但实际焦点还在之前出来的view上,对比了两个view的WindowManager.LayoutParams参数设置,发现前一个view的flag参数为WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,后一个view的flag参数为WindowManager.LayoutParams.TYPE_PHONE,查了一下文档:

/**
         * Window type: phone.  These are non-application windows providing
         * user interaction with the phone (in particular incoming calls).
         * These windows are normally placed above all applications, but behind
         * the status bar.
         * In multiuser systems shows on all users' windows.
         */
        public static final int TYPE_PHONE              = FIRST_SYSTEM_WINDOW+2;
    
        /**
         * Window type: system window, such as low power alert. These windows
         * are always on top of application windows.
         * In multiuser systems shows only on the owning user's window.
         */
        public static final int TYPE_SYSTEM_ALERT       = FIRST_SYSTEM_WINDOW+3;

WindowManager.LayoutParams.TYPE_SYSTEM_ALERT优先级比较高,把后一个view改为WindowManager.LayoutParams.TYPE_SYSTEM_ALERT就能获得焦点了.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值