解决android 7.0 popwindow的showAsDropDown没有效果问题

当手机安卓系统为7.0时,showAsDropDown()不起效果,我们可以用showAtLocation来解决这个问题

if (Build.VERSION.SDK_INT < 24) {

brandPopup.showAsDropDown(parent);

} else {

// 获取控件的位置,安卓系统>7.0

int[] location = new int[2];

parent.getLocationOnScreen(location);

brandPopup.showAtLocation(parent, Gravity.NO_GRAVITY, 0, location[1] + parent.getHeight());

}

猜你喜欢

转载自blog.csdn.net/aimi99xy/article/details/79192281