获取高度
获取StatusBar高度¶
本文记录获取StatusBar高度的方法。
在activity中获取DecorView
,然后拿到可见区域WindowVisibleDisplayFrame。
private void getStatusBarHeight() {
Rect rectangle = new Rect();
Window window = getWindow();
window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
// rectangle.top 就是高度
Log.d(TAG, "getStatusBarHeight: " + rectangle.top);
}
本站作者: rustfisher.com | rf.cs@foxmail.com
示例地址: AndroidTutorial Gitee, Tutorial Github
| 反馈问题: -> Android issues - gitee
本文链接: https://www.an.rustfisher.com/android/ui/statusbar/get-status-bar-height/
|-> 本站文章最近更新
一家之言,仅当抛砖引玉。如有错漏,还请指出。下方的广告链接内容与本站无关。如果喜欢本站的内容,也可 -> 点击请作者喝咖啡 ,谢谢支持服务器。