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

popwindow显示在控件左方

2016-10-20 17:59 183 查看
需要计算弹窗左边缘离屏幕左边的距离,上边缘离屏幕上边的距离

至于在控件上方,和右边,可通过类似计算获得

view.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
int popupWidth = view.getMeasuredWidth();
int popupHeight = view.getMeasuredHeight();
int[] location = new int[2];
add_ibtn.getLocationOnScreen(location);
pop.showAtLocation(add_ibtn, Gravity.NO_GRAVITY, location[0] - popupWidth, location[1] + add_ibtn.getHeight() / 2 - popupHeight / 2);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: