当前位置: 代码迷 >> 综合 >> PopupWindow在Android7.0系统中显示位置错误
  详细解决方案

PopupWindow在Android7.0系统中显示位置错误

热度:58   发布时间:2023-10-19 21:03:37.0

想要popWindows正常在Android7.0系统正常显示,我们需要重写popWindows的showAsDropDown方法:


public class PopWindowSelectCondition extends PopupWindow {....代码省略....@Overridepublic void showAsDropDown(View anchor) {if (Build.VERSION.SDK_INT >= 24) {Rect rect = new Rect();anchor.getGlobalVisibleRect(rect);int h = anchor.getResources().getDisplayMetrics().heightPixels - rect.bottom;setHeight(h);}super.showAsDropDown(anchor);}....代码省略....
}

 

  相关解决方案