获取应用状态栏的高度
2016-03-22 13:17
295 查看
获取状态栏高度的像素值
/**
* 用于获取状态栏的高度。
*
* @return 返回状态栏高度的像素值。
*/
private int getStatusBarHeight() {
int statusBarHeight = 0;
if (statusBarHeight == 0) {
try {
Class<?> c = Class.forName("com.android.internal.R$dimen");
Object o = c.newInstance();
Field field = c.getField("status_bar_height");
int x = (Integer) field.get(o);
statusBarHeight = getResources().getDimensionPixelSize(x);
} catch (Exception e) {
e.printStackTrace();}
}return statusBarHeight;
}
/**
* 用于获取状态栏的高度。
*
* @return 返回状态栏高度的像素值。
*/
private int getStatusBarHeight() {
int statusBarHeight = 0;
if (statusBarHeight == 0) {
try {
Class<?> c = Class.forName("com.android.internal.R$dimen");
Object o = c.newInstance();
Field field = c.getField("status_bar_height");
int x = (Integer) field.get(o);
statusBarHeight = getResources().getDimensionPixelSize(x);
} catch (Exception e) {
e.printStackTrace();}
}return statusBarHeight;
}
相关文章推荐
- 100 个最佳 Ubuntu 应用(中)
- 在 AppImage、Flathub 和 Snapcraft 平台上搜索 Linux 应用
- 24 个必备的 Linux 应用程序
- 注册表趣味应用小集
- 远程控制技术的应用
- 路由器访问列表的应用
- xDSL技术及其应用
- 基于XML的桌面应用
- SQL Server 2008 R2 应用及多服务器管理
- ExtJS 2.0实用简明教程之应用ExtJS
- JSP应用的安全问题
- 前端开发必须知道的JS之闭包及应用
- Android编程实现应用自动更新、下载、安装的方法
- Geohash的原理、算法和具体应用探究
- PHP开发中AJAX技术的简单应用
- PHP答题类应用接口实例
- ASP.NET过滤器的应用方法介绍
- Android编程实现将应用强制安装到手机内存的方法
- 让Android应用不被杀死(killer)的方法
- Android提高之蓝牙传感应用实例