کم نور کردن نوارهای سیستم (منسوخ شده)
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این درس نحوه کم نور کردن نوارهای سیستم (یعنی وضعیت و نوارهای پیمایش) را در اندروید 4.0 (سطح API 14) و بالاتر توضیح می دهد. اندروید روش داخلی برای کم نور کردن نوارهای سیستم در نسخه های قبلی ارائه نمی دهد.
وقتی از این روش استفاده می کنید، اندازه محتوا تغییر نمی کند، اما نمادهای موجود در نوارهای سیستم به صورت بصری عقب می نشینند. به محض اینکه کاربر نوار وضعیت یا ناحیه نوار ناوبری صفحه را لمس کند، هر دو نوار کاملاً قابل مشاهده می شوند. مزیت این رویکرد این است که میلهها هنوز وجود دارند اما جزئیات آنها مبهم است، بنابراین تجربهای غوطهورکننده بدون به خطر انداختن دسترسی آسان به میلهها ایجاد میکند.
نوارهای وضعیت و پیمایش را کم نور کنید
میتوانید با استفاده از پرچم SYSTEM_UI_FLAG_LOW_PROFILE
وضعیت و نوارهای پیمایش را به صورت زیر کم نور کنید:
کاتلین
// This example uses decor view, but you can use any visible view.
activity?.window?.decorView?.apply {
systemUiVisibility = View.SYSTEM_UI_FLAG_LOW_PROFILE
}
جاوا
// 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. میله های سیستم قابل مشاهده.
نوارهای وضعیت و ناوبری را آشکار کنید
اگر میخواهید پرچمهای تنظیم شده با setSystemUiVisibility()
را به صورت برنامهنویسی پاک کنید، میتوانید این کار را به صورت زیر انجام دهید:
کاتلین
activity?.window?.decorView?.apply {
// Calling setSystemUiVisibility() with a value of 0 clears
// all flags.
systemUiVisibility = 0
}
جاوا
View decorView = getActivity().getWindow().getDecorView();
// Calling setSystemUiVisibility() with a value of 0 clears
// all flags.
decorView.setSystemUiVisibility(0);
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-29 بهوقت ساعت هماهنگ جهانی."],[],[],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```"]]