@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//去掉標題欄
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(ActivityLoginBinding.inflate(getLayoutInflater()).getRoot());
//設定全屏
WindowInsetsController controller = getWindow().getInsetsController();
controller.hide(WindowInsets.Type.systemBars());
int behavior3 = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
controller.setSystemBarsBehavior(behavior3);
}
如果有編輯還是顯示導航欄的解決方案(重寫onWindowFocusChanged):
/**
* 全屏顯示
*
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
WindowInsetsController controller = getWindow().getInsetsController();
// 隱藏狀態欄 導航欄 同時隱藏狀態欄和導航欄
controller.hide(WindowInsets.Type.systemBars());
// 向后模式
int behavior1 = WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_TOUCH;
// 沉浸模式
int behavior2 = WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE;
// 粘性沉浸模式
int behavior3 = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
controller.setSystemBarsBehavior(behavior3);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/549381.html
標籤:其他
下一篇:Flutter 的優缺點及前景
