従来
AndroidManifest.xml
<application>
<!--直接記述でよかった -->
android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen"
</application>
現在
AndroidManifest.xml
<application>
android:theme="@style/Theme.アプリ名"
アプリ独自スタイルを持ってきているのでそこで記述すればいいらしい。
(場所がわからなくなったらCtrlボタンで追ってみよう)
Themes.html
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.アプリ名" parent="Theme.Material3.Light.NoActionBar">
<!--追加 -->
<item name="android:windowFullscreen">true</item>
<!-- Customize your light theme here. -->
</style>
<style name="Theme.アプリ名" parent="Base.Theme.アプリ名" />
</resources>
おまけ Activtyごとに設定する
Activity
fun barHide(activity: Activity){
val windowInsetsController =
WindowCompat.getInsetsController(activity.window, activity.window.decorView)
windowInsetsController.systemBarsBehavior =
//隠れたシステムバーを表示
BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
ViewCompat.setOnApplyWindowInsetsListener(activity.window.decorView) { view, windowInsets ->
//両方のシステムバーを非表示
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
ViewCompat.onApplyWindowInsets(view, windowInsets)
}
}
公式パラメータ
上記のようにアクションバー、ナビゲーションバーを消すより
AndroidManifestでデフォルトを消して必要な時に表す方が自然。
デフォルトをどちらにするかはご自由に。