当前位置: 代码迷 >> 综合 >> popwindow 在android 7.0位置错误
  详细解决方案

popwindow 在android 7.0位置错误

热度:71   发布时间:2024-01-18 03:07:40.0

继承popwindow并覆写以下方法,亲测有效

@Overridepublic void showAsDropDown(View anchorView, int xoff, int yoff) {if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {int[] a = new int[2];anchorView.getLocationInWindow(a);showAtLocation(anchorView, Gravity.NO_GRAVITY, xoff, a[1] + anchorView.getHeight() + yoff);} else {super.showAsDropDown(anchorView, xoff, yoff);}}@Overridepublic void showAsDropDown(View anchorView) {if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {int[] a = new int[2];anchorView.getLocationInWindow(a);showAtLocation(anchorView, Gravity.NO_GRAVITY, 0, a[1] + anchorView.getHeight() + 0);} else {super.showAsDropDown(anchorView);}}
  相关解决方案