android 7.0 PopWinow BUG
2018-01-16 09:30
274 查看
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
相关文章推荐
- Android 7.0系统 PopupWindow的bug
- Android 7.0 ProgressDialog 出现dismiss时背景灰色遮罩层无法关闭BUG
- Android 7.0 pendingIntent bug(AlarmManager通过PendingIntent传递数据(跨进程数据传递
- android 7.0 popuwindow 位置弹出错误bug
- bug -- android 7.0 popwindow显示位置异常情况解决
- Android适配7.0,TextView属性Bug,坑
- android 7.0 PopupWindow bug修复,测试没啥问题
- 解决Android(7.0-7.1.2)在Work Mode中所有Webview崩溃的bug
- Android 4.4从图库选择图片并裁剪,由于系统版本不同导致Uri的bug的几种解决方案
- android 7.0 加入 android:directBootAware之关机闹钟无声
- Android 7.0 settings中添加新菜单
- Android的有关EditText的能多行显示但无法禁止自动换行的Bug!
- Android 7.0 SystemUI(2)--Multi-Window多窗口模式
- Android 7.0需要注意的一些坑
- Android设置Notification从网络中加载图片,解决点击无法消失的bug
- Android下调试.so库类的bug
- Android 7.0来的真快,来看看又来了些什么出人意料的东西(墙外搬运)
- Android 7.0 网络变化监听
- Android版本更新(适用于6.0/7.0)
- Android生存指南:解Bug策略和思路