Android下PopupWindow隐藏及显示(showAtLocation/showAsDropDown)
2013-01-18 17:16
281 查看
转载:http://orgcent.com/android-popupwindow-showasdropdown-showatlocation/
上一篇对PopupWindow的用法(位置、动画、焦点)做了详细介绍,具体查看Android中PopupWindow的用法(位置、动画、焦点)。下面说说PopupWindow的如何隐藏、显示及显示位置(showAtLocation/showAsDropDown)。
1、PopupWindow的隐藏
2、PopupWindow的显示及位置设置
第一个参数指定PopupWindow的锚点view,即依附在哪个view上。
第二个参数指定起始点为parent的右下角,第三个参数设置以parent的右下角为原点,向左、上各偏移10像素。
如果没有充足的空间显示PopupWindow,那么PopupWindow的左下角将位于anchor的左上角来显示。
上一篇对PopupWindow的用法(位置、动画、焦点)做了详细介绍,具体查看Android中PopupWindow的用法(位置、动画、焦点)。下面说说PopupWindow的如何隐藏、显示及显示位置(showAtLocation/showAsDropDown)。
1、PopupWindow的隐藏
1 2 3 4 | final PopupWindow window = mPageStatWin; if(null != window && window.isShowing()) { win.dismiss(); } |
1 | window.showAtLocation(parent, Gravity.RIGHT | Gravity.BOTTOM, 10,10); |
第二个参数指定起始点为parent的右下角,第三个参数设置以parent的右下角为原点,向左、上各偏移10像素。
1 2 3 4 | //将PopupWindow作为anchor的下拉窗口显示。即在anchor的左下角显示 window.showAsDropDown(anchor); //xoff,yoff基于anchor的左下角进行偏移。 window.showAsDropDown(anchor, xoff, yoff); |
相关文章推荐
- Android编程之PopupWindow隐藏及显示方法示例(showAtLocation,showAsDropDown)
- Android下PopupWindow隐藏及显示(showAtLocation/showAsDropDown)
- Android下PopupWindow隐藏及显示(showAtLocation/showAsDropDown)
- Android下PopupWindow隐藏及显示(showAtLocation/showAsDropDown)
- 【Android 非常基础】PopupWindow showAtLocation和showAsDropDown参数分析
- PopupWindow showAtLocation和showAsDropDown参数分析
- PopupWindow showAtLocation和showAsDropDown参数分析
- Android开发之PopupWindow的showAtLocation()和showAsDropDown()
- showAsDropDown && showAtLocation
- 【Android 非常基础】PopupWindow showAtLocation和showAsDropDown参数分析
- PopupWindow之showAtLocation,showAsDropDown
- 关于Android popupWindow的位置显示 showAtLocation理解
- PopupWindow.showAtLocation理解
- Android PopupWindow怎么合理控制弹出位置(showAtLocation)
- 显示&隐藏Grid(Hide Grid Column & Show Grid Column)
- Fragment重叠,使用show和hide控制显示和隐藏界面重叠问题;
- (转)关于PopupWindow的showAsDropDown()和showAtLocation()使用方式及其区别
- Android7.0 ,7.1,8.0 popupwindow showAsDropDown 显示异常解决办法
- 显示和隐藏FC字段(Hide Control & Show Control)
- js中标签的显示与隐藏操作hide&show