• 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);
            }
        }
    }
  • 相关阅读:
    查看MySQL数据库版本
    PHP如何查找一列有序数组是否包含某值(二分查找)
    TP数据查询给sql给查询加一个虚拟字段值
    TP SQL统计查询语法
    PHP如何对一组数进行重新排列(冒泡算法)
    python入门及数字、字符串类型
    GitHub及Git及GitHub搭建个人网站
    Editplus的扩展程序的删除
    50个SQL语句(MySQL版) 问题十五
    50个SQL语句(MySQL版) 问题十四
  • 原文地址:https://www.cnblogs.com/androidsuperman/p/6563756.html
Copyright © 2020-2023  润新知