PopupWindow杂谈
来源:互联网 发布:java中super的作用 编辑:程序博客网 时间:2024/06/06 18:56
如果要将PopupWindow居中时,直接:
popupWindow.showAtLocation(findViewById(R.id.btnBack), Gravity.CENTER, 0, 0);//设置居中,经测试,第一个参数可以不是整个视图,只要是视图中的一个按钮都可以的了;
我试过在PopupWindow的view布局中用RelativeLayout将view设置layout_centerInParent="true",layout_height已经设置成wrap_content,但效果看到的layout_height高度还是match_parent,经过排查,就是layout_centerInParent="true"导致的,这不科学嘛!因为我已经在其它都用了layout_height="wrap_content",但高度还是占据整个屏幕,这个真心不懂。。。。
PopupWindow点击消失
1.设置背景
不需要颜色:popupWindow.setBackgroundDrawable(new BitmapDrawable());
自定义颜色:
// 实例化一个ColorDrawable颜色为半透明ColorDrawable bg = new ColorDrawable(0xb0000000);// 设置PopupWindow弹出窗体的背景popupWindow.setBackgroundDrawable(bg);
2.popupWindow.setOutsideTouchable(true);
PopupWindow弹出后设置背景透明度
// 设置背景颜色变暗WindowManager.LayoutParams lp = getWindow().getAttributes();lp.alpha = 0.3f;getWindow().setAttributes(lp);
在消失的时候将透明度变回来
popupWindow.setOnDismissListener(new OnDismissListener() {@Overridepublic void onDismiss() {// TODO Auto-generated method stubWindowManager.LayoutParams lp = getWindow().getAttributes();lp.alpha = 1f;getWindow().setAttributes(lp);}});
0 0
- PopupWindow杂谈
- popupwindow
- popupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- popupwindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- popupwindow
- popupwindow
- 什么是ADSL?它有哪些特点
- LeetCode 题解(58): Integer to Roman
- Java 导出EXCEL
- 第九周项目二——分数的累加
- 第九周项目 6 穷举法解决组合问题(换分币)
- PopupWindow杂谈
- 小企业智能路由器的应用 (用智能路由器推广你的烤肉饭)
- 学生A希望访问网站www.ss.edu.cn,用户A在其浏览器中输入http://www.ss.edu.cn并按回车,直到西亚斯的网站首页显示在其浏览器中,请问:在此过程中,按照TCP/IP参考模型,
- 写一个 docker 实战一个系列手册
- 简述网络设备集线器、网桥、交换机、路由器的基本原理
- 11种方法助你成为开源编程能手
- ArcGIS 中的拓扑概述
- java面试题
- codeforces 482B Interesting Array 线段树