本文翻译自:Height of status bar in Android
What's the height of the status bar in Android? Android中状态栏的高度是多少? Is it always the same? 总是一样的吗?
From my measurements it seems that it's 25dp, but I'm not sure if it has the same height on all platforms. 根据我的测量结果,它似乎是25dp,但我不确定它是否在所有平台上具有相同的高度。
(I want to know this to properly implement a fade transition from an activity that doesn't have status bar to one that does) (我想知道这是为了正确实现从没有状态栏的活动到执行状态栏的活动的淡入淡出过渡)
#1楼
参考:https://stackoom.com/question/EINk/Android中状态栏的高度
#2楼
Out of all the code samples I've used to get the height of the status bar, the only one that actually appears to work in the onCreate
method of an Activity
is this: 在我用来获取状态栏高度的所有代码示例中,实际看起来在Activity
的onCreate
方法中工作的唯一一个是:
public int getStatusBarHeight() {
int result = 0;
int resourceId = getResources().getIdentifier("status_bar_height", "