zoukankan      html  css  js  c++  java
  • 震惊 Android7.0居然出现这样的bug(popupwindow展示充满屏幕,而不是在view下方 )

    我的一个页面中用到了popupwindow,之前都没问题的,测试跑来说android7.0不对了,把原来的button挡住了(点击button弹出popupwindow)

    重写showAsDropDown(view)就解决了。

    public class SupportPopupWindow extends PopupWindow {
    
        public SupportPopupWindow(View contentView, int width, int height){
            super(contentView,width,height);
        }
    
        @Override
        public 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);
        }
    
        @Override
        public void showAsDropDown(View anchor, int xoff, int yoff) {
            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, xoff, yoff);
        }
    }
  • 相关阅读:
    微信开发:MySQL utf8mb4 字符集
    Spring 事务
    Exception
    mysql系列之多实例介绍
    python连接MySQL
    1_archlinux_安装篇
    apache中如何调用CGI脚本
    1.1_Django简介及安装
    git分支合并脚本
    用python收集系统信息
  • 原文地址:https://www.cnblogs.com/cherrylv/p/6565443.html
Copyright © 2011-2022 走看看