Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1048154
  • 博文数量: 403
  • 博客积分: 10272
  • 博客等级: 上将
  • 技术积分: 4407
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-24 14:22
文章分类

全部博文(403)

文章存档

2012年(403)

分类: 嵌入式

2012-05-08 16:40:07

碰到了需要获取状态栏高度的问题。

就像android后期版本,无法直接退出一样。找了一些方法来获取状态栏高度,结果都是为0.

还好,牛人是很多的,当时,找到一段代码,能够有效的获取状态栏的高度。特此记录,备忘,以及供大家参考。

Class c = null;
Object obj = null;
Field field = null;
int x = 0, sbar = 0;
try {
    c = Class.forName("com.android.internal.R$dimen");
    obj = c.newInstance();
    field = c.getField("status_bar_height");
    x = Integer.parseInt(field.get(obj).toString());
    sbar = getResources().getDimensionPixelSize(x);
} catch (Exception e1) {
    loge("get status bar height fail");
    e1.printStackTrace();

 同时,也希望看小说的朋友们,可以使用下兄弟做的小应用,自我感觉阅读翻页效果还凑合(自己制作的哈)。

萧潜 飘邈之旅 :

慕容湮儿 倾世皇妃 :

效果图:

  

阅读(2624) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~