מומלץ לצפות בחלק מהתוכן במסך מלא ללא אינדיקטורים משורת הסטטוס או בסרגל הניווט. דוגמאות לפריטים כאלה הן סרטונים, משחקים, גלריות תמונות, ספרים ושקופיות של מצגות. נקרא במצב עשיר. בדף הזה נסביר איך אפשר לעורר עניין רב יותר בקרב המשתמשים באמצעות תוכן במסך מלא.

מצב עשיר עוזר למשתמשים להימנע מיציאות מקריות במהלך משחק מספק חוויה סוחפת של הנאה מתמונות, מסרטונים ומספרים. עם זאת, חשוב לשים לב לתדירות שבה משתמשים נכנסים לאפליקציות ויוצאים מהן כדי לבדוק התראות, כדי לבצע חיפושים ספונטניים או לבצע פעולות אחרות. כי מצב של צפייה היקפית תגרום למשתמשים לאבד את הגישה בקלות לניווט במערכת. צריך להשתמש במצב של צפייה היקפית בלבד כשהיתרון של חוויית המשתמש הוא מעבר לשימוש במסך נוסף המרחב המשותף.
שימוש ב-WindowInsetsControllerCompat.hide()
כדי להסתיר את סרגלי המערכת ואז WindowInsetsControllerCompat.show()
כדי להחזיר אותם.
בקטע הקוד הבא מוצגת דוגמה להגדרת לחצן להסתרה ולהצגה פסי המערכת.
override fun onCreate(savedInstanceState: Bundle?) { ... val windowInsetsController = WindowCompat.getInsetsController(window, window.decorView) // Configure the behavior of the hidden system bars. windowInsetsController.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE // Add a listener to update the behavior of the toggle fullscreen button when // the system bars are hidden or revealed. ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { view, windowInsets -> // You can hide the caption bar even when the other system bars are visible. // To account for this, explicitly check the visibility of navigationBars() // and statusBars() rather than checking the visibility of systemBars(). if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars()) || windowInsets.isVisible(WindowInsetsCompat.Type.statusBars())) { binding.toggleFullscreenButton.setOnClickListener { // Hide both the status bar and the navigation bar. windowInsetsController.hide(WindowInsetsCompat.Type.systemBars()) } } else { binding.toggleFullscreenButton.setOnClickListener { // Show both the status bar and the navigation bar. windowInsetsController.show(WindowInsetsCompat.Type.systemBars()) } } ViewCompat.onApplyWindowInsets(view, windowInsets) } }
@Override protected void onCreate(Bundle savedInstanceState) { ... WindowInsetsControllerCompat windowInsetsController = WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView()); // Configure the behavior of the hidden system bars. windowInsetsController.setSystemBarsBehavior( WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE ); // Add a listener to update the behavior of the toggle fullscreen button when // the system bars are hidden or revealed. ViewCompat.setOnApplyWindowInsetsListener( getWindow().getDecorView(), (view, windowInsets) -> { // You can hide the caption bar even when the other system bars are visible. // To account for this, explicitly check the visibility of navigationBars() // and statusBars() rather than checking the visibility of systemBars(). if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars()) || windowInsets.isVisible(WindowInsetsCompat.Type.statusBars())) { binding.toggleFullscreenButton.setOnClickListener(v -> { // Hide both the status bar and the navigation bar. windowInsetsController.hide(WindowInsetsCompat.Type.systemBars()); }); } else { binding.toggleFullscreenButton.setOnClickListener(v -> { // Show both the status bar and the navigation bar. windowInsetsController.show(WindowInsetsCompat.Type.systemBars()); }); } return ViewCompat.onApplyWindowInsets(view, windowInsets); }); }
אפשר גם לציין את סוג שורת הסטטוס של המערכת שרוצים להסתיר, ולהגדיר את ההתנהגות שלה כשהמשתמש יוצר איתה אינטראקציה.
ציון העמודות של המערכת שרוצים להסתיר
כדי לציין את סוג שורות המערכת שרוצים להסתיר, מעבירים את אחד מהפרמטרים הבאים ל-WindowInsetsControllerCompat.hide()
.
שימוש ב-
WindowInsetsCompat.Type.systemBars()
כדי להסתיר את שני סרגלי המערכת.כדי להסתיר רק את שורת הסטטוס, משתמשים ב-
WindowInsetsCompat.Type.statusBars()
.משתמשים ב-
WindowInsetsCompat.Type.navigationBars()
כדי להסתיר רק את סרגל הניווט.
ציון ההתנהגות של שורות המערכת המוסתרות
משתמשים ב-WindowInsetsControllerCompat.setSystemBarsBehavior()
כדי לציין איך סרגל המערכת המוסתר יתנהג כשהמשתמש יבצע איתו אינטראקציה.
שימוש ב-
WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH
כדי לחשוף עמודות מערכת מוסתרות בכל אינטראקציה של משתמש מסך.שימוש ב-
WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
כדי לחשוף סרגלי מערכת מוסתרים בכל תנועות המערכת, כמו החלקה מ קצה המסך שבו הסרגל מוסתר.שימוש ב-
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
כדי לחשוף באופן זמני סרגלי מערכת מוסתרים באמצעות תנועות מערכת, כמו להחליק מקצה המסך שבו הסרגל מוסתר. האלה סרגלי מערכת זמניים מסתירים את תוכן האפליקציה, ועשויים לכלול מידה מסוימת והם מוסתרים באופן אוטומטי אחרי זמן קצוב לתפוגה.