一、PopupWindow: Android 7.0之前,在指定位置弹出popupwindow可以用showAsDropDown(View anchor, int xoff, int yoff),showAtLocation(View parent, int gravity, int x, int y)。但在android 7.0上,用showAsDropDown()在popupwindow为全屏时,会有弹出位置异常情况,需用showAtLocation()才能正常显示:
if (Build.VERSION.SDK_INT < 24)
{
dropListPopupWindow.showAsDropDown(this, 0, 5);
}
else
{
// 适配 android 7.0int[] location = newint[2];
getLocationOnScreen(location);
int x = location[0];
int y = location[1];
Log.e(getClass().getSimpleName(), "x : " + x + ", y : " + y);
dropListPopupWindow.showAtLocation(this, Gravity.NO_GRAVITY, 0, y + getHeight() + 5);
}
一、PopupWindow: Android 7.0之前,在指定位置弹出popupwindow可以用showAsDropDown(View anchor, int xoff, int yoff),showAtLocation(View parent, int gravity, int x, int y)。但在android 7.0上,用showAsDropDown()在popupwindo