使用
@L_@R_403_448@_0@的多窗口支持,如何检测状态栏是否可见?例如,当以纵向方向时,状态栏可能是可见的,如果我是顶级应用程序,但是当我是底层应用程序时,它们将不可见.现在,我的观点在底部是有趣的,因为我为不再存在的状态栏腾出空间.
解决方法
假设你的意思是系统UI栏,即状态栏这样做:
View decorView = getWindow().getDecorView(); decorView.setOnsystemUIVisibilityChangeListener (new View.OnsystemUIVisibilityChangeListener() { @Override public void onsystemUIVisibilityChange(int visibility) { // Note that system bars will only be "visible" if none of the // LOW_PROFILE,HIDE_NAVIGATION,or FULLSCREEN flags are set. if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { // TODO: The system bars are visible. Make any desired // adjustments to your UI,such as showing the action bar or // other navigational controls. } else { // TODO: The system bars are NOT visible. Make any desired // adjustments to your UI,such as hiding the action bar or // other navigational controls. } }
});
这是直接从文档:
https://developer.android.com/training/system-ui/visibility.html