借助 Android 的多窗口支持,如何检测状态栏是否可见?例如,在纵向时,如果我是顶部应用程序,状态栏可能可见,但当我是底部应用程序时,状态栏将不可见。现在,我的观点在底部时很有趣,因为我为不再存在的状态栏腾出了空间。
问问题
1582 次
1 回答
-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
于 2016-10-01T15:53:45.507 回答