api 25 PopupWindow会占据整个屏幕

解决方法:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // Android 7.x,PopupWindow高度为match_parent,会出现兼容性问题,需要处理兼容性
int[] mLocation = new int[2];
stephenCommonTopTitleView.getTopTitleView().getLocationInWindow(mLocation);
int offsetY = mLocation[1] + stephenCommonTopTitleView.getTopTitleView().getHeight();
if (Build.VERSION.SDK_INT >= 25) { // Android 7.1中,PopupWindow高度为 match_parent 时,会占据整个屏幕
//故而需要在 Android 7.1上再做特殊处理
WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
int screenHeight = wm.getDefaultDisplay().getHeight();
centWinShare.setHeight(screenHeight - offsetY); // 重新设置 PopupWindow 的高度
}
centWinShare.showAtLocation(stephenCommonTopTitleView.getTopTitleView(), Gravity.NO_GRAVITY, 0, offsetY);
} else {
centWinShare.showAsDropDown(stephenCommonTopTitleView.getTopTitleView());
}

思路大概是这样
/*if (Build.VERSION.SDK_INT != 24) {
//只有24这个版本有问题,好像是源码的问题
showAsDropDown(view);
} else {
//7.0 showAsDropDown没卵子用 得这么写
int[] location = new int[2];
view.getLocationOnScreen(location);
int x = location[0];
int y = location[1];
showAtLocation(view, Gravity.NO_GRAVITY, 0, y + view.getHeight());
//showAsDropDown(view, 0, marginTop);
}*/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值