Is there a way to check the visibility of the status bar?

后端 未结 4 1121
鱼传尺愫
鱼传尺愫 2020-12-29 13:25

I have a service that should check periodically visibility of status bar, when some top activity is (or not) in fullscreen mode. Is it possible?

4条回答
  •  盖世英雄少女心
    2020-12-29 13:50

    public boolean isStatusBarVisible() {
        Rect rectangle = new Rect();
        Window window = getActivity().getWindow();
        window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
        int statusBarHeight = rectangle.top;
        return statusBarHeight != 0;
    }
    

提交回复
热议问题