0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Android システムバー設定(ナビゲーションバー・アクションバー)

Last updated at Posted at 2025-01-23

従来

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でデフォルトを消して必要な時に表す方が自然。
デフォルトをどちらにするかはご自由に。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?