Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Vết cắt trên màn hình là một vùng trên một số thiết bị, mở rộng vào bề mặt màn hình. Thiết kế này mang đến trải nghiệm tràn viền, đồng thời vẫn có không gian cho các cảm biến quan trọng ở mặt trước của thiết bị.
Hình 1. Ví dụ về ảnh cắt trong Chế độ chân dungHình 2. Ví dụ về ảnh cắt ở chế độ ngang
Android hỗ trợ vết cắt trên màn hình trên các thiết bị chạy Android 9 (API cấp 28) trở lên. Tuy nhiên, các nhà sản xuất thiết bị cũng có thể hỗ trợ vết cắt trên màn hình trên các thiết bị chạy Android 8.1 trở xuống.
Trang này mô tả cách triển khai tính năng hỗ trợ cho các thiết bị có vết cắt trong Compose, bao gồm cả cách thao tác với vùng vết cắt – tức là hình chữ nhật tràn viền trên bề mặt màn hình có chứa vết cắt.
Trường hợp mặc định
Theo mặc định, các ứng dụng nhắm đến API cấp 34 trở xuống hoặc các Hoạt động không gọi enableEdgeToEdge sẽ không vẽ vào vùng vết cắt, trừ phi ứng dụng vẽ vào một thanh hệ thống có chứa vết cắt trên màn hình.
Ứng dụng nhắm đến API cấp 35 trở lên trên các thiết bị chạy Android 15 trở lên hoặc các Hoạt động gọi enableEdgeToEdge, vẽ vào vùng vết cắt.
Nói cách khác, LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT, LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES và LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER được diễn giải là LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS đối với các cửa sổ không nổi trong những ứng dụng nhắm đến API cấp 35 trở lên trên các thiết bị chạy Android 15 trở lên.
Xử lý thông tin về vết cắt theo cách thủ công
Bạn phải xử lý thông tin về vết cắt để ngăn vùng vết cắt che khuất văn bản, chế độ điều khiển hoặc các phần tử tương tác quan trọng đòi hỏi khả năng nhận dạng thao tác chạm chính xác (độ nhạy cảm ứng có thể thấp hơn trong vùng vết cắt). Khi xử lý vết cắt, đừng mã hoá cứng chiều cao thanh trạng thái vì điều này có thể dẫn đến nội dung bị chồng chéo hoặc bị cắt. Thay vào đó, hãy xử lý vết cắt theo một trong những cách sau:
Đối với Compose, bạn nên dùng displayCutout, safeContent hoặc safeDrawing để xử lý phần lồng ghép vết cắt trong các thành phần kết hợp. Phương pháp này cho phép bạn tuân thủ khoảng đệm của vết cắt trên màn hình khi cần hoặc bỏ qua khoảng đệm đó khi không cần.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-09-09 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-09 UTC."],[],[],null,["A *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\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\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/30ed522851a9273c94afcd3a4c30bf674346ad18/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- 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)"]]