android getDecorView()的作用

decorView是window中的最顶层view,可以从window中通过getDecorView获取到decorView。
通过decorView获取到程序显示的区域,包括标题栏,但不包括状态栏。间接可以计算状态栏高度。
比如计算状态栏的高度:

  Rect frame = new Rect();
  getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
  int statusBarHeight = frame.top;

 

posted @ 2016-01-28 14:08  星辰之力  阅读(5696)  评论(0编辑  收藏  举报