您的位置:首页 > 运维架构

popupWindow 设置指定的出现位置

2016-09-11 15:18 190 查看

我是通过showAtLocation(View parent, int Gravity, int x, int y)这个方法来确定位置的

1.得到指定的view在屏幕上的位置

int[] location = new int[2];
//flagView是parent
flagView.getLocationOnScreen(location);


2.指定位置(location[0] 和 location[1] 代表了parent左上角点的x、y)

//这个是正下方中间的显示
mPopupWindow.showAtLocation(flagView, Gravity.NO_GRAVITY,
location[0] + (rect.width() - windowView.getMeasuredWidth()) / 2, location[1] + rect.height());


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: