Android多窗口支持:检测状态栏是否可见?

前端之家收集整理的这篇文章主要介绍了Android多窗口支持:检测状态栏是否可见?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
使用 @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

原文链接:https://www.f2er.com/android/312021.html

猜你在找的Android相关文章