zoukankan      html  css  js  c++  java
  • bug -- android 7.0 popwindow显示位置异常情况解决

     android 7.0 popwindow显示位置异常,在android7.1官方进行解决了,但是还是要多7.0的bug进行解决,我的解决方案里面通过重写popwindow进行适配:

    import android.content.Context;
    import android.os.Build;
    import android.util.AttributeSet;
    import android.view.Gravity;
    import android.view.View;
    import android.widget.PopupWindow;
    
    /**
     * 解决7.0 popwindow显示位置的问题
     * Created by soyoungboy on 2017/3/16.
     */
    
    public class FixPopWindow extends PopupWindow {
        public FixPopWindow() {
        }
    
    
        public FixPopWindow(View contentView) {
            super(contentView);
        }
    
    
        public FixPopWindow(View contentView, int width, int height) {
            super(contentView, width, height);
        }
    
    
        public FixPopWindow(View contentView, int width, int height, boolean focusable) {
            super(contentView, width, height, focusable);
        }
    
    
        public FixPopWindow(Context context) {
            super(context);
        }
    
    
        public FixPopWindow(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
    
        public FixPopWindow(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
        }
    
    
        public FixPopWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
            super(context, attrs, defStyleAttr, defStyleRes);
        }
    
    
        public FixPopWindow(int width, int height) {
            super(width, height);
        }
    
    
        @Override public void showAsDropDown(View anchorView) {
            super.showAsDropDown(anchorView);
            if (Build.VERSION.SDK_INT == 24) {
                int[] a = new int[2];
                anchorView.getLocationInWindow(a);
                showAtLocation(anchorView, Gravity.NO_GRAVITY, 0, a[1] + anchorView.getHeight() + 0);
            } else {
                super.showAsDropDown(anchorView);
            }
        }
    
    
        @Override
        public void showAsDropDown(View anchorView, int xoff, int yoff) {
            if (Build.VERSION.SDK_INT == 24) {
                int[] a = new int[2];
                anchorView.getLocationInWindow(a);
                showAtLocation(anchorView, Gravity.NO_GRAVITY, xoff,
                    a[1] + anchorView.getHeight() + yoff);
            } else {
                super.showAsDropDown(anchorView, xoff, yoff);
            }
        }
    }
  • 相关阅读:
    flex属性导图
    html代码换行造成空格间距问题
    iconfont作用在css伪类中的写法
    JS模态框 简单案例
    JS实时获取输入框中的值
    JS封装addClass、removeClass
    特效 左右滑动轮播图jQuery思路
    JS 字符串两边截取空白的trim()方法的封装
    JavaScript易混淆知识点小回顾--数组方法与字符串方法;
    用GitHub来展示前端页面
  • 原文地址:https://www.cnblogs.com/androidsuperman/p/6563756.html
Copyright © 2011-2022 走看看