获取android手机屏幕的宽高、density
2016-07-20 17:25
441 查看
public static String getDisplayMetrics(Context cx) { String str = ""; DisplayMetrics dm = new DisplayMetrics(); dm = cx.getApplicationContext().getResources().getDisplayMetrics(); int screenWidth = dm.widthPixels; int screenHeight = dm.heightPixels; float density = dm.density; float xdpi = dm.xdpi; float ydpi = dm.ydpi; str += "The absolute width:" + String.valueOf(screenWidth) + "pixels\n"; str += "The absolute heightin:" + String.valueOf(screenHeight) + "pixels\n"; str += "The logical density of the display.:" + String.valueOf(density) + "\n"; str += "X dimension :" + String.valueOf(xdpi) + "pixels per inch\n"; str += "Y dimension :" + String.valueOf(ydpi) + "pixels per inch\n"; return str; }
相关文章推荐
- Binary XML File异常的解决
- Android adb connection Error
- Android 全局异常捕获
- 安卓Android轻松完成支付宝支付教程
- Android图片验证码
- android 进程通信之aidl 自定义数据类型
- ANDROID WebSocket+STOMP 1.0版本
- Android中一些简单操作
- android的初步学习---拨号器
- androidone -小插件倒计时
- Android Image 圆角图片与圆形图片 ImageView
- LeakCanary: 让内存泄露无所遁形
- Facebook的强大Android图片加载的框架:Fresco
- Android-LOG错误查看
- Android Studio你不知道的快捷键
- 下一代Android打包工具,100个渠道包只需要10秒钟
- android错误之android.content.res.Resources$NotFoundException:
- Android桌面悬浮窗效果实现,仿360手机卫士悬浮窗效果
- Android Studio调试技巧
- Android动画效果translate、scale、alpha、rotate详解