「问题描述」:

正常显示:

显示错位:

「解决方案」:

package com.chitty.views;import android.graphics.Rect;import android.os.Build;import android.view.View;import android.widget.PopupWindow;/** * Created by chitty on 2017/7/26. * 适配 Android 7.0  7.1 */public class FixedPopupWindow extends PopupWindow {    public FixedPopupWindow(View contentView, int width, int height) {        super(contentView, width, height, false);    }    @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);    }}

P.S. :
Android 7.0 的 Build.VERSION.SDK_INT = 24,
Android 7.1 的 Build.VERSION.SDK_INT = 25.

更多相关文章

  1. Android(安卓)USB gadget
  2. Android中Java和JavaScript交互解决方案,以及问题解决大全
  3. Android(安卓)Studio安装后Gradle同步失败问题的有效解决方案
  4. Android(安卓)sdk 接入时遇到的错误解决方案
  5. Unity打包Android提示找不到jdk解决方案
  6. Android短信拦截解决方案
  7. android webview ZoomButtonsController 导致android.view.Windo
  8. 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Fedora镜像
  9. 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Debian镜像

随机推荐

  1. Android利用系统提供的函数或常量判断版
  2. Android TextView 自定义字体设置
  3. android环境配置及android opencv环境配
  4. android通过manifest.xml设置程序安装的
  5. android ids.xml
  6. 安卓程序的入口点
  7. Android 数据存储四种方式
  8. Android:SystemUi有关notification
  9. Android的计时组件Chronometer类简单使用
  10. Android源码阅读之Looper