【虚拟按键】虚拟键适配PopupWindow显示位置
来源:互联网 发布:java打印杨辉三角10行 编辑:程序博客网 时间:2024/04/28 04:03
可以发现,虚拟键位,挡住了取消按钮的触控区域,网上百度一下,大多是在布局内家加上(Android:fitsSystemWindows=”true”) ,BUT我的控件不是布局,里面写好的啊!我采用的自定义布局,SO 问题就是如何让取消按钮的触控区域显示出来。
解决办法:获取虚拟键高度,然后定位显示布局的位置
public static Point getNavigationBarSize(Context context) { Point appUsableSize = getAppUsableScreenSize(context); Point realScreenSize = getRealScreenSize(context); // navigation bar on the right if (appUsableSize.x < realScreenSize.x) { return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y); } // navigation bar at the bottom if (appUsableSize.y < realScreenSize.y) { return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y); } // navigation bar is not present return new Point();}public static Point getAppUsableScreenSize(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size;}public static Point getRealScreenSize(Context context) { WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); Point size = new Point(); if (Build.VERSION.SDK_INT >= 17) { display.getRealSize(size); } else if (Build.VERSION.SDK_INT >= 14) { try { size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display); size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display); } catch (IllegalAccessException e) {} catch (InvocationTargetException e) {} catch (NoSuchMethodException e) {} } return size;}
使用的话 Point position = getNavigationBarSize(mContext);
position.y 就是需要的坐标
测试:虚拟键位正常显示在布局下面
链接地址:stackOverFlow
原文来自简书:http://www.jianshu.com/p/31d8c0097e47
0 0
- 【虚拟按键】虚拟键适配PopupWindow显示位置
- android 虚拟键适配PopupWindow显示位置
- android 虚拟键适配PopupWindow显示位置
- 底部虚拟按键挡住PopupWindow显示
- PopupWindow使用和遮挡虚拟按键处理
- Android虚拟按键适配Popupwindow
- miui显示虚拟按键方法
- 虚拟按键
- android4.0虚拟按键的显示
- android 修改源码控制系统虚拟按键显示
- android 虚拟按键menu显示/隐藏问题
- 显示、隐藏NavigationBar(虚拟按键)
- 控制虚拟按键的显示与隐藏
- 显示和隐藏虚拟按键的方法
- PopupWindow遮住虚拟键盘
- 隐藏与显示华为等有虚拟按键手机的虚拟按键
- 虚拟按键总结列表
- 特殊按键虚拟码
- 单片机学习(一)__led灯
- 浏览器和服务器在基于https进行请求链接到数据传输过程中,用到了如下哪些技术
- QT 5.8 新特性
- android 内外置SD卡的研究
- Educational Codeforces Round 2 D. Area of Two Circles' Intersection
- 【虚拟按键】虚拟键适配PopupWindow显示位置
- 【NOIP模拟】千帆渡
- 标注文件格式转换功能的简单实现
- JavaScript强化教程 —— Cocos2d-JS自动JSB绑定规则修改
- 1041. Be Unique (20)
- 文件
- gem5模拟器安装
- java常用的数组、字符串、集合操作以及数据结构与算法基本知识
- 日期操作类 Date->long,long->Date