点击一个popupwindow窗口之外的区域popupwindow消失,带来的问题!!
发布日期:2021-10-17 15:07:10
浏览次数:2
分类:技术文章
本文共 1196 字,大约阅读时间需要 3 分钟。
popupwindow窗口之外的区域popupwindow消失 , 以前说过需要设置:
mPopupWindow.setFocusable(true); // 设置PopupWindow可获得焦点 mPopupWindow.setTouchable(true); // 设置PopupWindow可触摸 mPopupWindow.setOutsideTouchable(true); // 设置非PopupWindow区域可触摸 mPopupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.chooseballbg));// // 这句话必须有,否则 // // 按返回键 // // popwindow不能消失 或者加入这句话 // ColorDrawable dw = new ColorDrawable(-00000); // mPopupWindow.setBackgroundDrawable(dw);但是: 加入这些之后,我给Popwindow加了动画的,出现一个恶心的问题:就是popwindow在执行动画过程中,如果Popwindow上有button类似的控件,控件有背景色的变化,就会带来非常恶心的现象: 点击的控件的那一块竟然出现漏洞了,透明的一块,这就是
mPopupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.chooseballbg));//带来的恶果!! 咋办呢? 我这样做的:这句话我不用了!! 用别的方法来实现popwindow的dismiss。
用这种方法:就是利用popwindow内部的控件加入按键事件!!
这样的:
LinearLayout layouttemp = (LinearLayout) view .findViewById(R.id.linearlayout_blank); layouttemp.setFocusable(true); layouttemp.setFocusableInTouchMode(true); layouttemp.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // 手机键盘上的返回键 switch (keyCode) { case KeyEvent.KEYCODE_BACK: mPopupWindow.dismiss(); break; } return false; } });即可!!
转载地址:https://blog.csdn.net/tenggangren/article/details/8703193 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
做的很好,不错不错
[***.243.131.199]2024年03月26日 05时20分47秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【Leetcode刷题篇】leetcode300 最长上升子序列
2019-04-26
【Leetcode刷题篇】leetcode394 字符串解码
2019-04-26
【Leetcode刷题篇】leetcode152 乘积最大数组
2019-04-26
【Leetcode刷题篇】leetcode56 合并区间
2019-04-26
【Leetcode刷题篇】leetcode210 课程表II
2019-04-26
【Leetcode刷题篇】leetcode207 课程表
2019-04-26
【Leetcode刷题篇】leetcode322 零钱兑换
2019-04-26
【Leetcode刷题篇】leetcode437 路径总和III
2019-04-26
【Linux篇】Linux常用命令之性能优化
2019-04-26
【面试篇】JVM体系
2019-04-26
【Leetcode刷题篇】leetcode406 根据身高重建队列
2019-04-26
【Leetcode刷题篇】leetcode581 最短无序连续子数组
2019-04-26
【Leetcode刷题篇】leetcode538 把二叉搜索树转换为累加树
2019-04-26
【多线程与高并发】线程的优先级是怎么回事?
2019-04-26
【多线程与高并发】Java守护线程是什么?什么是Java的守护线程?
2019-04-26
【Leetcode刷题篇/面试篇】-前缀树(Trie)
2019-04-26
【Leetcode刷题篇】leetcode337 打家劫舍III
2019-04-26
【Leetcode刷题篇】leetcode4 寻找两个正序数组的中位数
2019-04-26
【Leetcode刷题篇】leetcode316 去除重复字母
2019-04-26
【Leetcode刷题篇】leetcode1081 不同字符的最小子序列
2019-04-26