美文网首页Android知识Android开发Android技术知识
华为手机7.0以上华为7.0上popwindow位置显示错乱

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

作者: Lazy1 | 来源:发表于2017-02-17 11:01 被阅读336次

由于测试手机上华为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位置显示错乱

    本文链接:https://www.haomeiwen.com/subject/ntvkwttx.html