这个属性开启后可以保持Modal一直在状态栏下,键盘弹出时不会将Modal整体向上推,对于Modal顶部有输入键盘的比较有用。
源码:
/**
* Returns the view that will be the root view of the dialog. We are wrapping this in a
* FrameLayout because this is the system's way of notifying us that the dialog size has changed.
* This has the pleasant side-effect of us not having to preface all Modals with "top:
* statusBarHeight", since that margin will be included in the FrameLayout.
*/
private View getContentView() {
FrameLayout frameLayout = new FrameLayout(getContext());
frameLayout.addView(mHostView);
if (mStatusBarTranslucent) {
frameLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
} else {
frameLayout.setFitsSystemWindows(true);
}
return frameLayout;
}
关键代码frameLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
它能保持Activity在状态栏下全屏显示。