Android中PopupWindow showAsDropDown()弹出位置异常问题

解决办法:

在继承PopupWindow后 ,重写showAsDropDown()方法,我遇到的问题是 在打开软键盘后动态关闭键盘显示位置出现问题
原因:在android 7.0后PopupWindow显示位置存在绘制错误。

复制代码进行粘贴就可以。

@Override

public void showAsDropDown(View anchor) {

if (Build.VERSION.SDK_INT <24) {

super.showAsDropDown(anchor);

    }else {

int[] location =new int[2];

        anchor.getLocationOnScreen(location);

        int x = location[0];

        int y = location[1];

        super.showAtLocation(anchor, Gravity.NO_GRAVITY, 0, y + anchor.getHeight());

    }

}

你可能感兴趣的:(Android中PopupWindow showAsDropDown()弹出位置异常问题)