android 7.0 PopupWindow bug修复,测试没啥问题

    xiaoxiao2021-03-25  79

    View view = LayoutInflater.from(this).inflate(R.layout.xxx, null); popupWindow = new PopupWindow(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true) { @Override public void showAsDropDown(View anchor) { Class<?> popupwindow = PopupWindow.class; try { Method m2 = popupwindow.getDeclaredMethod("computeGravity"); m2.setAccessible(true); int invoke = (int) m2.invoke(popupWindow); int gravity = Gravity.START | Gravity.TOP; if (invoke == gravity) { Rect rect = new Rect(); anchor.getGlobalVisibleRect(rect); int h = anchor.getResources().getDisplayMetrics().heightPixels - rect.bottom; setHeight(h); } } catch (Exception e) { e.printStackTrace(); } super.showAsDropDown(anchor); } }; popupWindow.setBackgroundDrawable(new BitmapDrawable()); popupWindow.showAsDropDown(dropView);
    转载请注明原文地址: https://ju.6miu.com/read-14984.html

    最新回复(0)