Android下PopupWindow隐藏及显示(showAtLocation/showAsDropDown)
16lz
2021-01-25
转载:http://orgcent.com/android-popupwindow-showasdropdown-showatlocation/
上一篇对PopupWindow的用法(位置、动画、焦点)做了详细介绍,具体查看Android中PopupWindow的用法(位置、动画、焦点)。下面说说PopupWindow的如何隐藏、显示及显示位置(showAtLocation/showAsDropDown)。
1、PopupWindow的隐藏
1 2 3 4 | final PopupWindow window = mPageStatWin ; if ( null != window && window. isShowing ( ) ) { win. dismiss ( ) ; } |
2、PopupWindow的显示及位置设置
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开发之ExpandableListView
- [android] android下文件访问的权限
- Android(安卓)NDK几点回调方式(device id & signature)
- 初探Android平台上的定位服务(GPS)
- Android程序框架
- Eclipse如何开发Android?
- android功耗(9)----MTK功耗问题需要哪种log
- Android相册中获取图片和路径
- Android学习:TextUtils类介绍