システムバーを暗くする(非推奨)
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
<ph type="x-smartling-placeholder">
このレッスンでは、システムバー(ステータスバーとナビゲーション バー)を暗くする方法について説明します。
バー)が表示されます。Android には、デバイスを暗くする機能が組み込まれていません。
表示されます。
この方法を使用すると、コンテンツのサイズ変更は行われず、システムバーのアイコンは変更されます。
視覚が後退しますユーザーがステータスバーかナビゲーション バーの
両方のバーが完全に表示されます。この方法の利点は、
棒は残されているものの、その詳細が不明瞭になっているという手法です。
バーへのアクセスのしやすさを犠牲にすることなく、臨場感あふれるエクスペリエンスを実現しています。
ステータスバーやナビゲーション バーを省略表示にする
ステータスバーとナビゲーション バーを暗くするには、
次のように SYSTEM_UI_FLAG_LOW_PROFILE
フラグを指定します。
Kotlin
// This example uses decor view, but you can use any visible view.
activity?.window?.decorView?.apply {
systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE
}
Java
// This example uses decor view, but you can use any visible view.
View decorView = getActivity().getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE;
decorView.setSystemUiVisibility(uiOptions);
ユーザーがステータスバーまたはナビゲーション バーに触れるとすぐにフラグがクリアされ、
バーの色が薄くなります。フラグがクリアされたら、アプリをリセットする必要があります。
バーを再度暗くしたい場合はオンにします。
図 1 は、ナビゲーション バーがグレー表示になっているギャラリー画像です(ギャラリー アプリは
ステータスバーを完全に非表示にする暗くならない)。ナビゲーション バー(右側の
(画像の側面)に薄い白い点が付いており、ナビゲーション コントロールを表しています。
図 1. 省略表示状態のシステムバー
同じギャラリー画像で、システムバーが表示されている状態を図 2 に示します。
図 2. 表示状態のシステムバー
ステータスバーやナビゲーション バーを表示する
「terraform destroy」コマンドを実行し、
setSystemUiVisibility()
、できます
次のとおりです。
Kotlin
activity?.window?.decorView?.apply {
// Calling setSystemUiVisibility() with a value of 0 clears
// all flags.
systemUiVisibility = 0
}
Java
View decorView = getActivity().getWindow().getDecorView();
// Calling setSystemUiVisibility() with a value of 0 clears
// all flags.
decorView.setSystemUiVisibility(0);
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Dim the system bars (deprecated)\n\n| **Deprecated:** [setSystemUiVisibility](/reference/android/view/View#setSystemUiVisibility(int)) is deprecated in API Level 30\n\nThis lesson describes how to dim the system bars (that is, the status and the navigation\nbars) on Android 4.0 (API level 14) and higher. Android does not provide a built-in way to dim the\nsystem bars on earlier versions.\n\nWhen you use this approach, the content doesn't resize, but the icons in the system bars\nvisually recede. As soon as the user touches either the status bar or the navigation bar area of\nthe screen, both bars become fully visible. The advantage of this\napproach is that the bars are still present but their details are obscured, thus\ncreating an immersive experience without sacrificing easy access to the bars.\n\nDim the Status and Navigation Bars\n----------------------------------\n\nYou can dim the status and navigation bars using the\n[SYSTEM_UI_FLAG_LOW_PROFILE](/reference/android/view/View#SYSTEM_UI_FLAG_LOW_PROFILE) flag, as follows: \n\n### Kotlin\n\n```kotlin\n// This example uses decor view, but you can use any visible view.\nactivity?.window?.decorView?.apply {\n systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE\n}\n```\n\n### Java\n\n```java\n// This example uses decor view, but you can use any visible view.\nView decorView = getActivity().getWindow().getDecorView();\nint uiOptions = View.SYSTEM_UI_FLAG_LOW_PROFILE;\ndecorView.setSystemUiVisibility(uiOptions);\n```\n\nAs soon as the user touches the status or navigation bar, the flag is cleared,\ncausing the bars to be undimmed. Once the flag has been cleared, your app needs to reset\nit if you want to dim the bars again.\n\nFigure 1 shows a gallery image in which the navigation bar is dimmed (note that the Gallery app\ncompletely hides the status bar; it doesn't dim it). Notice that the navigation bar (right\nside of the image) has faint white dots on it to represent the navigation controls:\n\n\n**Figure 1.** Dimmed system bars.\n\nFigure 2 shows the same gallery image, but with the system bars displayed:\n\n\n**Figure 2.** Visible system bars.\n\nReveal the Status and Navigation Bars\n-------------------------------------\n\nIf you want to programmatically clear flags set with\n[setSystemUiVisibility()](/reference/android/view/View#setSystemUiVisibility(int)), you can do so\nas follows: \n\n### Kotlin\n\n```kotlin\nactivity?.window?.decorView?.apply {\n // Calling setSystemUiVisibility() with a value of 0 clears\n // all flags.\n systemUiVisibility = 0\n}\n```\n\n### Java\n\n```java\nView decorView = getActivity().getWindow().getDecorView();\n// Calling setSystemUiVisibility() with a value of 0 clears\n// all flags.\ndecorView.setSystemUiVisibility(0);\n```"]]