//获取屏幕尺寸,不包括虚拟功能高度

getWindowManager().getDefaultDisplay().getHeight();

获取屏幕原始尺寸高度,包括虚拟功能键高度,

private int getDpi()
{ int dpi = 0;
Display display = getWindowManager().getDefaultDisplay();
DisplayMetrics dm = new DisplayMetrics();
@SuppressWarnings("rawtypes")
Class c;
try {
c = Class.forName("android.view.Display");
@SuppressWarnings("unchecked")
Method method = c.getMethod("getRealMetrics",DisplayMetrics.class);
method.invoke(display, dm);
dpi=dm.heightPixels;
}catch(Exception e){
e.printStackTrace();
}
return dpi;
}

  通过两个高度的对比,可以知道设备是否拥有虚拟功能建,Android4.0以后出现的虚拟功能键,对界面布局的兼容性有较大影响,记录之。

  

Android获取屏幕实际高度跟显示高度,判断Android设备是否拥有虚拟功能键的更多相关文章

  1. Android获取屏幕宽和高

    android获取屏幕的高度和宽度用到WindowManager这个类,两种方法:   1.WindowManager wm = (WindowManager) getContext()        ...

  2. Android 获取屏幕大小和密度

    Android 获取屏幕大小和密度 DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay ...

  3. Android获取屏幕大小和设置无标题栏

    android获取屏幕大小非常常用,例如写个程序,如果要做成通用性很强的程序,适用屏幕很强,一般布局的时候都是根据屏幕的长宽来定义的,所以我把这个总结一下,方便日后忘记的时候查阅.还有就是有时候写程序 ...

  4. Android 获取屏幕分辨率

    原文:Android 获取屏幕分辨率 得到一个屏幕尺寸的三种方法如下:        // 通过WindowManager获取        DisplayMetrics dm = new Displ ...

  5. Android获取屏幕大小

    本来想着如下方法就能得到了 Display display = getWindowManager().getDefaultDisplay(); Log.i("view", &quo ...

  6. android 获取屏幕的高度和宽度、获取控件在屏幕中的位置、获取屏幕中控件的高度和宽度

    (一)获取屏幕的高度和宽度 有两种方法: 方法1: WindowManager wm = (WindowManager) getContext().getSystemService(Context.W ...

  7. JS 获取浏览器窗口大小 获取屏幕,浏览器,网页高度宽度

    网页可见区域宽:document.body.clientWidth 网页可见区域高:document.body.clientHeight 网页可见区域宽:document.body.offsetWid ...

  8. android获取屏幕长宽的方法

    package com.kale.imageview02; import android.annotation.SuppressLint; import android.app.Activity; i ...

  9. Android 获取屏幕尺寸与密度

      android中获取屏幕的长于宽,参考了网上有很多代码,但结果与实际不符,如我的手机是i9000,屏幕大小是480*800px,得到的结果却为320*533 结果很不靠谱,于是自己写了几行代码,亲 ...

随机推荐

  1. android Menu

    menu <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="h ...

  2. php请求返回GeoJSON格式的数据

    <?php /* * Following code will list all the products */ // array for JSON response $response = ar ...

  3. Eclipse 调试的时候Tomcat报错启动不了

    Eclipse 调试的时候Tomcat报错启动不了 1.把所有的断点删掉 2.清理工程 3.在Tomcat里面删除项目 4.删除Tomcat的配置,重新配置一下

  4. [poj2182] Lost Cows (线段树)

    线段树 Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacula ...

  5. ReportService未指定 OverwriteDataSources

    报表服务器部署好之后,查看报表就显示ConnectionString 属性尚未初始化. 然后重启部署并查看部署时控制台的输出信息,发现之前的部署成功消息是假象,实际上部署的时候有一个警告: 不能将数据 ...

  6. HTML5滑动(swipe)事件

    移动H5开发中经常用到滑动效果(页面上移.下移.向左滑动.向右滑动等),浏览器并没有内置swipe事件,可以通过touch事件(touchstart.touchmove和touchend)模拟swip ...

  7. 【Android 疑难杂症1】android.content.ActivityNotFoundException: Unable to find explicit activity class

    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.cnote ...

  8. CheckBox复选框全选以及获取值

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...

  9. git命令大集合

    git 使用整理 密钥生成 cd ~/.ssh //检查本机中是否有公钥信息 mkdir key_backup cp id_rsa*key_backup rm id_rsa //删除已有公钥 &quo ...

  10. 用到的一些python包,记录下

    Requests beautifulsoup lxml logging gevent django Bottle numpy pandas sklearn pyopencv opencv_python ...