华为手机7.0以上华为7.0上popwindow位置显示错乱

由于测试手机上华为meta8,升级了7.0以后突然popwindows显示位置往上飘了, 其他机型没啥问题,一直没找到原因?后来看到一个连接?

https://code.google.com/p/android/issues/detail?id=221001

原来是 in showAtLocation failed to no gravity 在7.0上没有工作

解决方法是:

  if (android.os.Build.VERSION.SDK_INT >=24) {
                               int[] a = new int[2];
                               v.getLocationInWindow(a);
                               mPopupWindow.showAtLocation(((Activity) context).getWindow().getDecorView(), Gravity.NO_GRAVITY, 0 , a[1]+v.getHeight());
                           } else{
                               mPopupWindow.showAsDropDown(v);
                           }

你可能感兴趣的:(华为手机7.0以上华为7.0上popwindow位置显示错乱)