PopupWindow 适配 Android(安卓)7.0 、7.1
16lz
2022-06-17
「问题描述」:
正常显示:
显示错位:
「解决方案」:
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.
更多相关文章
- Android(安卓)USB gadget
- Android中Java和JavaScript交互解决方案,以及问题解决大全
- Android(安卓)Studio安装后Gradle同步失败问题的有效解决方案
- Android(安卓)sdk 接入时遇到的错误解决方案
- Unity打包Android提示找不到jdk解决方案
- Android短信拦截解决方案
- android webview ZoomButtonsController 导致android.view.Windo
- 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Fedora镜像
- 【阿里云镜像】切换阿里巴巴开源镜像站镜像——Debian镜像