当手机安卓系统为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());
}