问题描述: popupWindow使用popupwidow 使用showAsDropDown 显示在自定控件之下,在7.0之前的系统能显示正常,在7.0的系统不能正确的显示指定控件的下方
解决方案: 重写public void showAsDropDown(View anchor);
@Override
public void showAsDropDown(View anchor) { if (Build.VERSION.SDK_INT >= 24) {// 只有7.0 的系统有这个问题 mEditText.setFocusable(false); HideKeyboard(mEditText); int[] location = new int[2]; anchor.getLocationOnScreen(location); int x = location[0]; int y = location[1]; showAtLocation(anchor, Gravity.NO_GRAVITY, 0, y + anchor.getHeight()); } else { super.showAsDropDown(anchor); } }