edge-to-edge
它能做什么
这个技能把 Jetpack Compose 应用迁移到全面屏(edge-to-edge)显示。它会修复被导航栏或状态栏遮挡的按钮和列表,以及键盘遮挡的问题。适合希望界面完整铺满屏幕的 Android 开发者。
适用场景
- ✓当你的 Compose 应用中的按钮或列表位于导航栏或状态栏之下的时候。
- ✓当 Compose 界面中的键盘遮挡了文本输入框时。
- ✓当你的界面上状态栏或导航栏的文字难以阅读的时候。
技能链接
https://github.com/android/skills/blob/main/system/edge-to-edge/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 Compose 应用底部按钮被导航栏遮住了。请让应用实现全面屏显示并修复它。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能首先找出每个需要全面屏支持的 Activity 和列表。然后它会在每个 Activity 中启用全面屏,设置键盘调整模式,并应用系统内边距,使关键内容始终可以点击。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Prerequisites
- Project MUST use Android Jetpack Compose.
- Project MUST target SDK 35 or later. If the SDK is lower than 35, increase the SDK to 35.
Step 1: plan
- Locate and analyze all Activity classes to detect which have existing edge-to-edge support. For every Activity without edge-to-edge, plan to make each Activity edge-to-edge.
- In each Activity, Locate and analyze all lists and FAB components to detect which have existing edge-to-edge support. For every component without edge-to-edge support, plan to make each of these components edge-to-edge.
- In each Activity, scan for
TextField,OutlinedTextField, orBasicTextField. If found, then you MUST verify the IME doesn't hide the input field by following the IME section of this skill.
Step 2: add edge-to-edge support
- Add
enableEdgeToEdgebeforesetContentinonCreatein each Activity that does not already callenableEdgeToEdge. - Add
android:windowSoftInputMode="adjustResize"in the AndroidManifest.xml for all Activities that use a soft keyboard.
Step 3: apply insets
The app MUST apply system insets, or align content to rulers, so critical UI remains tappable. Choose only one method to avoid double padding:
- PREFERRED: When available, use
Scaffolds and passPaddingValuesto the content lambda.
<br />Scaffold { innerPadding -> // innerPadding accounts for system bars and any Scaffold components LazyColumn( modifier = Modifier .fillMaxSize() .consumeWindowInsets(innerPadding), contentPadding = innerPadding ) { /* Content */ } }PREFERRED: When available, use the automatic inset handling or padding modifiers in material components.
- Material 3 Components manages safe areas for its own components, including:
TopAppBarSmallTopAppBarCenterAlignedTopAppBarMediumTopAppBarLargeTopAppBarBottomAppBarModalDrawerSheetDismissibleDrawerSheetPermanentDrawerSheetModalBottomSheetNavigationBarNavigationRail
- For Material 2 Components, use the
windowInsetsparameter to apply insets manually forBottomAppBar,TopAppBarandBottomNavigation. DO NOT apply padding to the parent container; instead, pass insets directly to the App Bar component. Applying padding to the parent container prevents the App Bar background from drawing into the system bar area. For example, forTopAppBar, choose only one of the following options:- PREFERRED:
TopAppBar(windowInsets = AppBarDefaults.topAppBarWindowInsets) TopAppBar(windowInsets = WindowInsets.systemBars.exclude(WindowInsets.navigationBars))TopAppBar(windowInsets = WindowInsets.systemBars.add(WindowInsets.captionBar))
- PREFERRED:
- Material 3 Components manages safe areas for its own components, including:
For components outside a Scaffold, use padding modifiers, such as
Modifier.safeDrawingPadding()orModifier.windowInsetsPadding(WindowInsets.safeDrawing).
<br />Box( modifier = Modifier .fillMaxSize() .safeDrawingPadding() ) { Button( onClick = {}, modifier = Modifier.align(Alignment.BottomCenter) ) { Text("Login") } }For deeply nested components with excessive padding, use
WindowInsetsRulers(e.g.Modifier.fitInside(WindowInsetsRulers.SafeDrawing.current)). See the IME section for a code sample.When you need an element (e.g. a custom header or decorative scrim) to equal the dimensions of a system bar, use inset size modifiers (e.g.
Modifier.windowInsetsTopHeight(WindowInsets.systemBars)). See the Lists section for a code sample.
- PREFERRED: When available, use
Adaptive Scaffolds
NavigationSuiteScaffoldmanages safe areas for its own components, like theNavigationRailorNavigationBar. However, the adaptive scaffolds (e.g.NavigationSuiteScaffold,ListDetailPaneScaffold) don't propagate PaddingValues to their inner contents. You MUST apply insets to individual screens or components (e.g., listcontentPaddingor FAB padding) as described in Step 3 . DO NOT applysafeDrawingPaddingor similar modifiers to theNavigationSuiteScaffoldparent. This clips and prevents an edge-to-edge screen.
IME
- For each Activity with a soft keyboard, check that `andr
常见问题
应用需要以什么 Android 版本为目标?
应用必须以 SDK 35 或更高版本为目标,如果应用版本较低,该技能会将其提高到 35。
它会重复添加内边距吗?
该技能的设计是通过同一个方法应用内边距,以避免重复填充。
它涵盖 Android Views 应用吗?
不涵盖。应用必须使用 Jetpack Compose。
详情
作者的原始描述
Use this skill to migrate your Jetpack Compose app to add adaptive edge-to-edge support and troubleshoot common issues. Use this skill to fix UI components (like buttons or lists) that are obscured by or overlapping with the navigation bar or status bar, fix IME insets, and fix system bar legibility.
repo: android/skills
热度
- GitHub 星标
- 10k
- 排名
- #11934
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/29
评论
- …
同一仓库的更多技能
agp-9-upgrade
10k帮你的智能体把 Android 应用升级到 Android Gradle Plugin 9,并处理其中的破坏性变更。不适用于多平台项目。
camerax
10k帮你的智能体使用 CameraX 构建 Android 相机功能,包括视频录制、硬件控制以及 ML Kit 和 Media3 效果。
android-for-cars-parked-apps
10k帮你的智能体把 Android 视频、游戏或浏览器应用调整为可在 Android Auto 和 Android Automotive 上以停放应用形式运行。
appfunctions
10k帮你的智能体在 Android 应用中找到关键工作流,并把它们暴露为 AI 智能体和语音命令可以运行的 AppFunctions。