android 7.0 PopWinow BUG

1.showAsDropDown()的全屏BUG
mPopupWindow = PopupWindow(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
                .apply {
                    val inflate = View.inflate(context, R.layout.layout_around_pop, null)
                    inflate.onClick { dismiss() }
                    val recyclerView = inflate.find<RecyclerView>(R.id.mRecyclerView)
                    recyclerView.layoutManager = GridLayoutManager(activity, 5, GridLayoutManager.VERTICAL, false)
                    value= object : BaseRLAdapter<Clazz>(recyclerView, datas, R.layout.item_popwin_list) {
                        override fun loadMore() {
                            //这个方法不会走
                        }

                        override fun onConvert(holder: MyHolder?, list: List<Clazz>, position: Int) {
                            
                          
                        }
                    }
                    recyclerView.adapter = value
                    isOutsideTouchable = false
                    isFocusable = true
                    contentView = inflate

                }
        if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.M) {
            val location = IntArray(2)
            around_type_line.getLocationOnScreen(location)
            val y = location[1]
            mPopupWindow?.showAtLocation(around_type_line, Gravity.NO_GRAVITY, 0, y + QMUIDisplayHelper.dp2px(activity, 1))
        } else {
            mPopupWindow?.showAsDropDown(around_type_line)
        }
在showAsDropDown之前  进行了一次判断  复制即可 但不知道为什么 任然偶现全屏的BUG 
2.PopWindow在activity的onCreate中show的BUG(BadTokenException)
尝试1:onPostCreat OnCreate OnResume onWindowFocusChange 
override fun onWindowFocusChanged(hasFocus: Boolean) {
    super.onWindowFocusChanged(hasFocus)
    if (hasFocus && !isFirst) {
        isFirst = true
        initData()
    }
}
尝试2:配合Handler.postDelay()
除了 onWindowFocusChange 或者 配合Handler.postDelay() 能够不报错 其他统一报错(大概意思是 window未初始化 就show? 崩!) 但是别以为问题就此完结了。在调试SDK19(4.4.4)时居然死活不弹出来(此处需要Mark一下),这还不要紧 最要命的是splash界面 卡死了···。那怎么办呢?直接放弃PopWindow呗,毕竟项目是有周期的,先完成任务再说,直 View.GONE
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值