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);
        }
    }
  • 相关阅读:
    go学习中的零散笔记
    git reset --hard与git reset --soft的区别
    php必学必会
    gdb 解core
    php学习
    高仿京东到家APP引导页炫酷动画效果
    RxHttp
    SVN回滚文件
    遍历枚举
    python3 多线程
  • 原文地址:https://www.cnblogs.com/cherrylv/p/6565443.html
Copyright © 2011-2022 走看看