تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
بعد أن يستهدف تطبيقك الإصدار 35 من حزمة تطوير البرامج (SDK) أو إصدارًا أحدث، يتم فرض ميزة "العرض حتى حافة الشاشة". يكون شريط حالة النظام وأشرطة التنقّل بالإيماءات شفافة، بينما يكون شريط التنقّل بثلاثة أزرار شبه شفاف. اتّصِل بالرقم enableEdgeToEdge لجعل هذا التنسيق متوافقًا مع الأنظمة القديمة.
يمكنك إنشاء شريط تنقّل شفاف يستند إلى الإيماءات من خلال استهداف الإصدار 15 من نظام التشغيل Android أو الإصدارات الأحدث أو من خلال استدعاء enableEdgeToEdge() باستخدام وسيطات تلقائية للإصدارات الأقدم. بالنسبة إلى شريط التنقّل الذي يتضمّن ثلاثة أزرار، اضبط قيمة Window.setNavigationBarContrastEnforced على false، وإلا سيتم تطبيق طبقة شفافة.
إنشاء أشرطة نظام شفّافة
لإنشاء شريط حالة شبه شفاف، أنشئ عنصرًا قابلاً للإنشاء مخصّصًا يتداخل مع المحتوى الرئيسي ويرسم تدرّجًا في المنطقة التي تغطيها الحواف الداخلية.
classSystemBarProtectionSnippets:ComponentActivity(){overridefunonCreate(savedInstanceState:Bundle?){super.onCreate(savedInstanceState)// enableEdgeToEdge sets window.isNavigationBarContrastEnforced = true// which is used to add a translucent scrim to three-button navigationenableEdgeToEdge()setContent{MyTheme{// Main contentMyContent()// After drawing main content, draw status bar protectionStatusBarProtection()}}}}@ComposableprivatefunStatusBarProtection(color:Color=MaterialTheme.colorScheme.surfaceContainer,heightProvider:()->Float=calculateGradientHeight(),){Canvas(Modifier.fillMaxSize()){valcalculatedHeight=heightProvider()valgradient=Brush.verticalGradient(colors=listOf(color.copy(alpha=1f),color.copy(alpha=.8f),Color.Transparent),startY=0f,endY=calculatedHeight)drawRect(brush=gradient,size=Size(size.width,calculatedHeight),)}}@ComposablefuncalculateGradientHeight():()->Float{valstatusBars=WindowInsets.statusBarsvaldensity=LocalDensity.currentreturn{statusBars.getTop(density).times(1.2f)}}
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-08-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# About system bar protection\n\nOnce your app targets SDK 35 or later, [edge-to-edge is enforced](/about/versions/15/behavior-changes-15#edge-to-edge). The\nsystem status bar and gesture navigation bars are transparent, but the\nthree-button navigation bar is translucent. Call `enableEdgeToEdge` to make this\nbackwards compatible.\n\nHowever, the system defaults might not work for all use cases. Consult the\n[Android system bars design guidance](/design/ui/mobile/guides/foundations/system-bars) and [edge-to-edge design\nguidance](/design/ui/mobile/guides/layout-and-content/edge-to-edge) for an overview of when to consider having transparent or\ntranslucent system bars.\n\nCreate transparent system bars\n------------------------------\n\nCreate a transparent gesture navigation bar by targeting Android 15 or later or\nby calling `enableEdgeToEdge()` with default arguments for earlier versions. For\nthree-button navigation bar, set [`Window.setNavigationBarContrastEnforced`](/reference/android/view/Window#setNavigationBarContrastEnforced(boolean))\nto `false` otherwise there will be a translucent scrim applied.\n\nCreate translucent system bars\n------------------------------\n\nTo create a translucent status bar, create a custom composable that overlaps the\nmain content and draws a gradient in the area covered by insets.\n\n\n```kotlin\nclass SystemBarProtectionSnippets : ComponentActivity() {\n\n override fun onCreate(savedInstanceState: Bundle?) {\n super.onCreate(savedInstanceState)\n\n // enableEdgeToEdge sets window.isNavigationBarContrastEnforced = true\n // which is used to add a translucent scrim to three-button navigation\n enableEdgeToEdge()\n\n setContent {\n MyTheme {\n // Main content\n MyContent()\n\n // After drawing main content, draw status bar protection\n StatusBarProtection()\n }\n }\n }\n}\n\n@Composable\nprivate fun StatusBarProtection(\n color: Color = MaterialTheme.colorScheme.surfaceContainer,\n heightProvider: () -\u003e Float = calculateGradientHeight(),\n) {\n\n Canvas(Modifier.fillMaxSize()) {\n val calculatedHeight = heightProvider()\n val gradient = Brush.verticalGradient(\n colors = listOf(\n color.copy(alpha = 1f),\n color.copy(alpha = .8f),\n Color.Transparent\n ),\n startY = 0f,\n endY = calculatedHeight\n )\n drawRect(\n brush = gradient,\n size = Size(size.width, calculatedHeight),\n )\n }\n}\n\n@Composable\nfun calculateGradientHeight(): () -\u003e Float {\n val statusBars = WindowInsets.statusBars\n val density = LocalDensity.current\n return { statusBars.getTop(density).times(1.2f) }\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/layouts/SystemBarProtectionSnippets.kt#L53-L103\n```\n\n\u003cbr /\u003e\n\n**Figure 1.** A translucent status bar.\n\nFor adaptive apps, insert a custom composable that matches the colors of each\npane, as seen in the [Edge-to--edge design](/design/ui/mobile/guides/layout-and-content/edge-to-edge). To create a translucent\nnavigation bar, set [`Window.setNavigationBarContrastEnforced`](/reference/android/view/Window#setNavigationBarContrastEnforced(boolean)) to true."]]