تكون تجربة بعض المحتوى أفضل في وضع ملء الشاشة بدون أي مؤشرات على شريط الحالة أو شريط التنقل. ويشمل ذلك الفيديوهات والألعاب والصور. والمعارض والكتب وشرائح العروض التقديمية. ويُعرف هذا باسم الوضع الشامل. توضح هذه الصفحة كيف يمكنك جذب المستخدمين بشكل أكبر باستخدام المحتوى في وضع ملء الشاشة.

يساعد "الوضع الغامر" المستخدمين في تجنُّب الخروج من اللعبة بدون قصد، ويمنحهم تجربة غامرة للاستفادة من الصور والفيديوهات والكتب. ومع ذلك، يُرجى مراعاة عدد المرات التي يدخل فيها المستخدمون إلى التطبيقات ويخرجون منها للاطّلاع على الإشعارات. أو إجراء عمليات تفتيش غير مخطَّط لها أو اتّخاذ إجراءات أخرى لأنّ الوضع المجسم يتسبب في فقدان المستخدمين لإمكانية الوصول بسهولة إلى التنقل في النظام، واستخدام الوضع المجسم فقط عندما تتجاوز فائدة تجربة المستخدم مجرد استخدام الشاشة الإضافية مساحة.
استخدِم 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
للكشف مؤقتًا عن أشرطة النظام المخفية باستخدام إيماءات النظام، مثل التمرير السريع من حافة الشاشة حيث يتم إخفاء الشريط. تُظهر هذه أشرطة النظام المؤقتة فوق محتوى تطبيقك، وقد تتمتع بدرجة من الشفافية، ويتم إخفاؤها تلقائيًا بعد مهلة قصيرة.