获取状态栏高度(运用反射)
来源:互联网 发布:刚哥哥淘宝店招制作 编辑:程序博客网 时间:2024/05/01 14:42
public static int getStatusHeight(Activity activity) {int statusHeight = 0;Rect localRect = new Rect();activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);statusHeight = localRect.top;if (0 == statusHeight) {Class<?> localClass;try {localClass = Class.forName("com.android.internal.R$dimen");Object localObject = localClass.newInstance();int i5 = Integer.parseInt(localClass.getField("status_bar_height").get(localObject).toString());statusHeight = activity.getResources().getDimensionPixelSize(i5);} catch (ClassNotFoundException e) {e.printStackTrace();} catch (IllegalAccessException e) {e.printStackTrace();} catch (InstantiationException e) {e.printStackTrace();} catch (NumberFormatException e) {e.printStackTrace();} catch (IllegalArgumentException e) {e.printStackTrace();} catch (SecurityException e) {e.printStackTrace();} catch (NoSuchFieldException e) {e.printStackTrace();}}return statusHeight;}
以下代码不能放在oncreate中 否则height为0
Rect frame = new Rect();getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);statusBarHeight = frame.top;
0 0
- 获取状态栏高度(运用反射)
- 通过反射机制获取状态栏的高度
- Android利用反射获取状态栏(StatusBar)高度
- android通过反射获取状态栏的高度
- Android利用反射获取状态栏(StatusBar)高度
- Android通过反射获取屏幕大小,自动减去状态栏高度
- Android:获取状态栏高度
- Android 获取状态栏高度
- Android获取状态栏高度
- 获取状态栏高度
- 获取系统状态栏高度
- 获取状态栏高度
- android获取状态栏高度
- 获取状态栏高度
- android获取状态栏高度
- Android获取状态栏高度
- Android获取状态栏高度
- Android 获取状态栏高度
- 微软面试100题之14题:输入一个已经按升序排序过的数组和一个数字, 在数组中查找两个数,使得它们的和正好是输入的那个数字。
- iOS推送证书导出pem文件
- Java抽象类和接口的区别
- AIDL(安卓接口定义语言)
- java web安全总结
- 获取状态栏高度(运用反射)
- centos CentOS-6.2-i386-minimal 安装gnome桌面环境
- 深入理解Hadoop集群和网络
- 二路归并排序
- 每日一编c-7
- Content Providers(内容提供器)
- spring junit--基础配置
- Cracking The Coding Interview 4.2_暂存
- Linux设备模型(6)_Bus