借助Android的多窗口支持,如何检测状态栏是否可见?例如,当处于纵向方向时,如果我是顶级应用程序,则状态栏可能是可见的,但是当我在底部应用程序时,状态栏可能不可见。现在,我的观点在底部很有趣,因为我为状态栏腾出空间了。
答案 0 :(得分:-1)
假设您的意思是系统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