עמעום סרגלי המערכת (הוצא משימוש)
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
בשיעור הזה מתואר איך לעמעם את סרגלי המערכת (כלומר, הסטטוס וניווט
עמודות) ב-Android 4.0 (רמת API 14) ומעלה. ב-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. פסי מערכת גלויים.
הצגת סרגלי הסטטוס וסרגל הניווט
אם רוצים להסיר באופן פרוגרמטי דגלים שהוגדרו עם
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```"]]