קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
חיתוך תצוגה הוא אזור במכשירים מסוימים שמתרחב אל פני השטח של התצוגה. היא מאפשרת חוויה מקצה לקצה ומשאירה מקום לחיישנים חשובים בחלק הקדמי של המכשיר.
איור 1. דוגמה לחיתוך במצב 'דיוקן'איור 2. דוגמה לחיתוך בפריסה לרוחב
Android תומך בחלקים חתוכים במסך במכשירים עם Android מגרסה 9 (רמת API 28) ומעלה. עם זאת, יצרני מכשירים יכולים גם לתמוך בחיתוכי מסך במכשירים עם Android בגרסה 8.1 ומטה.
בדף הזה מוסבר איך להטמיע תמיכה במכשירים עם חורים במסך ב-Compose, כולל איך לעבוד עם אזור החור – כלומר, המלבן מקצה לקצה על משטח התצוגה שמכיל את החור.
מקרה ברירת מחדל
אפליקציות שמטרגטות את רמת ה-API 34 ומטה, או פעילויות שלא קוראות ל-enableEdgeToEdge, לא יציגו את עצמן באזור החיתוך כברירת מחדל, אלא אם האפליקציה מוצגת בסרגל מערכת שמכיל את החיתוך של המסך.
אפליקציות שמטרגטות רמת API 35 ומעלה במכשירים עם Android 15 ומעלה, או פעילויות שקוראות ל-enableEdgeToEdge, מציירות באזור החיתוך.
במילים אחרות, LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT,
LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES ו-LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER מתפרשים כ-LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS בחלונות לא צפים באפליקציות שמטרגטות רמת API 35 ומעלה במכשירים עם Android 15 ומעלה.
טיפול ידני במידע על חיתוך
צריך לטפל במידע על החלק החסר כדי למנוע מצב שבו האזור החסר מסתיר טקסט חשוב, אמצעי בקרה או רכיבים אינטראקטיביים שנדרשת בהם רגישות גבוהה למגע (הרגישות למגע עשויה להיות נמוכה יותר באזור החסר). כשמטפלים בחלקים חתוכים, לא כדאי להגדיר קידוד קשיח לגובה של סרגל הסטטוס, כי זה עלול לגרום לחפיפה או לחיתוך של התוכן. במקום זאת, אפשר לטפל בחלקים החסרים באחת מהדרכים הבאות:
לגבי Compose, מומלץ להשתמש ב-displayCutout, ב-safeContent או ב-safeDrawing כדי לטפל בתוספות של חיתוך ברכיבים הניתנים להרכבה. הגישה הזו מאפשרת לכם להשתמש בריווח של החלק החסר במסך כשצריך, או להתעלם ממנו כשלא צריך.
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-08-22 (שעון 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-08-22 (שעון UTC)."],[],[],null,["# About cutouts\n\nA *display cutout* is an area on some devices that extends into the display\nsurface. It allows for an *edge-to-edge* experience while providing space for\nimportant sensors on the front of the device.\n**Figure 1**. Cutout example in Portrait mode **Figure 2**. Cutout example in landscape mode\n\nAndroid supports display cutouts on devices running Android 9 (API level 28) and\nhigher. However, device manufacturers can also support display cutouts on\ndevices running Android 8.1 or lower.\n\nThis page describes how to implement support for devices with cutouts in\nCompose, including how to work with the *cutout area*--- that is, the edge-to-edge\nrectangle on the display surface that contains the cutout.\n\nDefault case\n------------\n\nApps targeting API level 34 or lower, or Activities that don't call\n`enableEdgeToEdge`, won't draw into the cutout region by default unless the app\ndraws into a system bar containing the display cutout.\n\nApps targeting API level 35 or higher on devices running Android 15 or\nhigher, or Activities that call `enableEdgeToEdge`, draw into the cutout region.\n\nIn other words, `LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT`,\n`LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES`, and\n`LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER` are interpreted as\n`LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS` for non-floating windows in apps\ntargeting API level 35 or higher on devices running Android 15 or\nhigher.\n\nHandle cutout information manually\n----------------------------------\n\nYou must handle cutout information to prevent the cutout area from obscuring\nimportant text, controls, or interactive elements requiring fine-touch\nrecognition (touch sensitivity may be lower in the cutout area). While handling\ncutouts, don't hardcode the status bar height, as this can lead to overlapping\nor cut-off content. Instead, handle cutouts in any of the following ways:\n\n- Using [`WindowInsets.displayCutout`](/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets.Companion).displayCutout()), [`WindowInsets.safeContent`](/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets.Companion).safeContent()), or\n [`WindowInsets.safeDrawing`](/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets.Companion).safeDrawing())\n\n- Accessing the cutout `Path` object with [`LocalView.current.rootWindowInsets.displayCutout`](/reference/kotlin/androidx/compose/ui/platform/package-summary#LocalView())\n\nFor Compose, we recommend that you use `displayCutout`, `safeContent`, or\n`safeDrawing` to handle cutout insets in your composables. This approach lets\nyou respect the display cutout padding where required, or ignore it where it is\nnot required.\n\n\n```kotlin\nCanvas(modifier = Modifier.fillMaxSize().windowInsetsPadding(WindowInsets.displayCutout)) {\n drawRect(Color.Red, style = Stroke(2.dp.toPx()))\n}https://github.com/android/snippets/blob/dd30aee903e8c247786c064faab1a9ca8d10b46e/compose/snippets/src/main/java/com/example/compose/snippets/system/CutoutSnippets.kt#L70-L72\n```\n\n\u003cbr /\u003e\n\nRecommended for you\n-------------------\n\n- Note: link text is displayed when JavaScript is off\n- [Window insets in Compose](/develop/ui/compose/layouts/insets)\n- [Graphics Modifiers](/develop/ui/compose/graphics/draw/modifiers)\n- [Style paragraph](/develop/ui/compose/text/style-paragraph)"]]