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);
        }
    }
  • 相关阅读:
    codeforces 363B
    hdu 1075 字典树
    D
    C A Simple Job
    Washing Plates 贪心
    HDU 4143 A Simple Problem 分解因式
    ACdream 1236 Burning Bridges 割边 + 去重边
    E. Beautiful Subarrays 字典树
    反素数 -- 数学
    Codeforces Beta Round #79 (Div. 1 Only) B. Buses 树状数组
  • 原文地址:https://www.cnblogs.com/cherrylv/p/6565443.html
Copyright © 2011-2022 走看看