public class SFPopupWindow extends PopupWindow {
public SFPopupWindow(Context context) {
super(context, null);
}
@Override
public void showAsDropDown(View anchor) {
if (Build.VERSION.SDK_INT == 24) {
Rect rect = new Rect();
anchor.getGlobalVisibleRect(rect);
int h = anchor.getResources().getDisplayMetrics().heightPixels - rect.bottom;
setHeight(h);
}
super.showAsDropDown(anchor);
}
}
解决PopupWindow在7.0以上位置不正确的bug
最新推荐文章于 2022-11-23 16:57:16 发布
本文介绍了一个名为SFPopupWindow的自定义PopupWindow类,该类针对API 24的设备进行了特别优化,确保了弹窗能够正确计算其高度并显示在用户界面上。通过检查设备的API版本并调整弹窗的高度,可以改善用户体验。
3263

被折叠的 条评论
为什么被折叠?



