skills/harmonyos-ai-agent-skill/references/hmos-multidevice-screen-window-size/SKILL.md
Handle HarmonyOS screen and window size adaptation, including breakpoint systems, responsive layouts, GridRow/GridCol usage, window size observation, and multi-device layout changes.
npx skillsauth add openharmonyinsight/openharmony-skills hmos-multidevice-screen-window-sizeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| 字段 | 内容 |
| --- |--------------------------------------------------------------------------------------|
| skill_id | screen-window-size |
| skill_name | 屏幕窗口尺寸适配 |
| one_line_purpose | 为多设备布局提供断点策略、结构切换策略和窗口监听策略。 |
| device_scope | phone / tablet / tv / 2in1 |
| problem_scope | 断点体系、响应式布局、窗口变化监听、媒体查询、字体缩放、显示密度 |
| not_in_scope | 纯业务逻辑重构、与尺寸无关的视觉微调 |
| primary_outputs | primary_scene、device_constraints、code_touchpoints、fix_plan、verification_matrix |
GridRow、GridCol 或其他响应式容器,而不是零散条件分支。FIX 阶段必须先保护单屏基线体验,再处理多屏问题;禁止出现“多屏改善但单屏明显退化”。onConfigurationUpdate 并通过 AppStorage 全局同步,不得遗漏环境变量响应。maxFontScale 限制时,必须说明是应用级配置还是组件级属性,以及限制倍数的依据。用户描述一个多设备布局需求(如"适配平板")或布局异常问题(如"折叠屏上布局断裂")。
SIZE-00,读取多设备适配规格要求。SIZE-01SIZE-02SIZE-03SIZE-04SIZE-05按匹配的阶段(REQ/DEV/FIX/VAL)输出对应契约字段。
| 标签 | 阶段 | 当前模块关注点 |
| --- | --- | --- |
| REQ | 需求分析设计 | 断点边界、设备范围、结构变化原则 |
| DEV | 开发 | 断点状态管理、容器选型、监听落点 |
| FIX | 问题修复 | 断点错配、布局断裂、状态未同步 |
| VAL | 功能验证 | 断点切换证据、窗口变化证据、布局稳定性 |
active_phases、primary_phase、primary_scene、secondary_scenes、resources_usedREQ:device_constraints、capability_boundary、acceptance_focusDEV:code_touchpoints、reuse_resources、implementation_notes、integration_risksFIX:problem_profile、root_cause_hypothesis、fix_plan、regression_watchlistVAL:verification_matrix、evidence_requirements、pass_criteria、residual_risksdevice_constraints:指由设备形态、窗口状态、输入方式或系统区域带来的适配硬约束。在 screen-window-size 中,通常是断点范围、主判定维度和不同尺寸下是否发生结构切换。它不是 API 列表,也不是代码修改点。capability_boundary:指当前方案支持到哪里、不支持什么、在哪些设备或窗口条件下需要降级或不处理。acceptance_focus:指需求阶段验收时必须重点确认的现象、证据或边界条件。deliverables.REQ 出现 device_constraints,表示“该场景一旦命中,在需求分析阶段必须产出这个字段”,不是对字段再定义一次。SIZE-00,读取规格要求。SIZE-01。SIZE-02。SIZE-03。SIZE-04。SIZE-05。startAbility + StartOptions 启动另一个 UIAbility 分屏显示)时,优先命中 SIZE-06。active_phases: [DEV, VAL]。SIZE-02,并联动 VAL:
ImageFit.Cover、容器高度、宽屏放大导致内容缺失或裁切component_stretch、图片四周被拉开、中心聚焦失真SIZE-00 多设备窗口适配规格阶段:REQ | 优先级:P0
适用场景
不适用场景
文件读取
REQ 阶段(读取 reference)
./references/adaptation-specification.md - 多设备适配规格要求DEV 阶段(按最佳实践读取 assets)
./assets/PipWindow.ets ⭐ 推荐方案 - SPEC-05 画中画能力完整示例(PipManager + CustomNodeController + 页面集成)SIZE-01 多设备适配窗口尺寸布局阶段:REQ / DEV / FIX | 优先级:P0
适用场景
不适用场景
关键决策
文件读取
REQ 阶段(读取 reference)
./references/breakpoint_system.md - 断点系统设计原理./references/responsive_layout.md - 四种响应式布局(重复布局、分栏布局、挪移布局、缩进布局)./references/adaptive_layout.md - 七种自适应能力(拉伸、缩放、隐藏、占比、折行、均分、延伸)./references/window_size_detection.md - 窗口监听机制DEV 阶段(按最佳实践读取 assets)
断点系统
./assets/SystemBreakpointExample.ets ⭐ 推荐方案 - 系统断点枚举./assets/BreakpointConstants.ets - 备选方案 - 自定义断点常量./assets/BreakpointType.ets - 简化条件渲染./assets/BreakpointObserver.ets - 断点观察器响应式布局
./assets/GridRowBreakpoints.ets - GridRow 内置断点./assets/GridRowExample.ets - 栅格布局示例./assets/GridColOffset.ets - 栅格偏移配置窗口监听
./assets/WindowSizeChangeListener.ets ⭐ 推荐方案 - 直接监听窗口尺寸变化./assets/MediaQueryManager.ets - 媒体查询管理器./assets/MediaQueryExample.ets - 媒体查询示例FIX 阶段(读取 reference)
./references/breakpoint_system.md - 断点系统设计原理./references/adaptive_layout.md - 七种自适应能力(拉伸、缩放、隐藏、占比、折行、均分、延伸)./references/window_size_detection.md - 窗口监听机制SIZE-02 尺寸异常修复阶段:DEV / FIX | 优先级:P1
适用场景
不适用场景
关键决策
图片拉伸专项规则(component_stretch)
根因判断(必须先判断再改)
ImageFit.Cover 与容器高度过低导致裁切,而非图片资源问题。禁止方案(命中任一即判高风险)
推荐方案(按顺序执行)
验收门禁(未全部满足不得宣称 GoodCase)
Image bounds 对比证据。文件读取
DEV 阶段(读取 assets)
./assets/small-square-screen-collapse.md - 小方形屏底部栏折叠./assets/scroll-page-content-clipped-by-full-height.md - 滚动内容裁剪./assets/alphabetindexer-autocollapse.md - 索引器自动折叠FIX 阶段(读取 reference)
./references/size-anomaly.md - 问题分类和根因分析SIZE-03 位置异常修复阶段:DEV / FIX | 优先级:P1
适用场景
不适用场景
关键决策
文件读取
DEV 阶段(读取 assets) 暂无内容
FIX 阶段(读取 reference)
./references/position-anomaly.md - 位置异常分类和根因SIZE-04 布局异常修复阶段:DEV / FIX | 优先级:P1
适用场景
不适用场景
关键决策
文件读取
DEV 阶段(读取 assets)
./assets/gridrow-breakpoints.md - GridRow 断点问题修复./assets/stack-overlap-occlusion.md - Stack 堆叠遮挡修复./assets/row-displaypriority-truncation.ets - Row/Column 组件截断优先级./assets/SplitScreenExample.ets - 分屏模式下截断问题修复FIX 阶段(读取 reference)
./references/layout-anomaly.md - 布局异常分类和根因SIZE-05 字体缩放与显示密度适配阶段:REQ / DEV / FIX | 优先级:P1
适用场景
不适用场景
关键决策
fontSizeMaxScale vs 组件级 maxFontScale vs 应用内自行管理onConfigurationUpdate + AppStorage 全局同步UIObserver.on('densityUpdate') + onSizeChangeconstraintSize 限制最大/最小尺寸文件读取
REQ 阶段(读取 reference)
./references/font_scale_display_density.md - 字体缩放与显示密度适配原理DEV 阶段(读取 assets) 暂无内容
FIX 阶段(读取 reference)
./references/font_scale_display_density.md - 字体缩放与显示密度适配原理SIZE-06 应用内分屏阶段:REQ / DEV / FIX | 优先级:P0
适用场景
startAbility + StartOptions 启动另一个 UIAbility 实现系统级分屏不适用场景
关键决策
preferMultiWindowOrientation 取值(default / portrait / landscape / landscape_auto)Want.parameters → LocalStorage → loadContent(path, storage) → @LocalStorageLink文件读取
REQ 阶段(读取 reference)
./references/split-screen.md - 应用内分屏完整指南DEV 阶段(按最佳实践读取 assets)
./assets/SplitScreenExample.ets - 分屏模式下截断问题修复FIX 阶段(读取 reference)
./references/split-screen.md - 应用内分屏常见问题表关键代码模式
Index.onClick(分屏) → startAbility(want+parameters, SPLIT_SECONDARY) → EntryAbility1.onCreate/onNewWant → writeParamsToStorage(want) → loadContent('DetailPage', storage) → @Entry({ useSharedStorage: true }) + @LocalStorageLink 绑定.hideTitleBar(true) 隐藏外层标题栏 + .navDestination(pageMap) 加载已有组件REQactive_phases、primary_phase、primary_scene、secondary_scenesdevice_constraints、capability_boundary、acceptance_focusDEVcode_touchpoints、reuse_resources、implementation_notes、integration_risksFIXproblem_profile、root_cause_hypothesis、fix_plan、regression_watchlistsingle_screen_guard(单屏不退化策略)和 multi_screen_guard(多屏不拉伸策略)
3.fix_plan 必须包含“先单屏基线、后多屏抑制、再裁切优化”的执行顺序VALverification_matrix、evidence_requirements、pass_criteria、residual_riskssmall / medium / large 或项目等价断点,并提供截图、布局 dump 或窗口尺寸证据
2.图片拉伸类问题必须覆盖单屏/双屏/三屏三个窗口宽度层级(项目等价值如 1008 / 2048 / 3184)
3.pass_criteria 必须包含以下客观项:
Image bounds 可对比且无异常拉伸趋势development
Run local code quality checks covering a subset of OpenHarmony gate CI (copyright, CodeArts C/C++) plus additional local checks (pylint/flake8, shellcheck/bashate, gn format). Use before committing to reduce gate failures. Triggers on: /oh-precommit-codecheck, "门禁检查", "门禁预检", "检查代码", "run codecheck", "check code quality", "lint my code", "代码检查", or after completing code implementation. WHEN to use: before git commit, before creating PR, after modifying C/C++/Python/Shell/GN files, when gate CI fails with codecheck defects, or when you want to preview what gate will flag.
development
OpenHarmony PR full lifecycle workflow. Five modes: - Commit: standardized commit with DCO sign-off and Issue linking - Create PR: commit + push to fork + create Issue + create PR on upstream - Fix Codecheck: fetch gate CI codecheck defects from a PR and auto-fix them - Review PR: fetch a PR's changes to local for code review - Fix Review: fetch unresolved review comments from a PR and auto-fix them Triggers on: /oh-pr-workflow, "提交代码", "创建PR", "提个PR", "commit", "修复告警", "修复门禁", "修复codecheck", "fix codecheck", "review pr", "review这个pr", "看下这个pr", "检视pr", "修复review", "修复检视意见", "fix review", or a GitCode PR URL with fix/review intent.
testing
分析 HM Desktop PRD 文档,提取需求信息、验证完整性、检查章节顺序(需求来源→需求背景→需求价值分析→竞品分析→需求描述)、检查 KEP 定义、检测需求冲突并生成结构化分析报告。适用于用户请求:(1) 分析或审查 PRD 文档, (2) 从需求中提取 KEP 列表, (3) 检查 PRD 完整性或一致性, (4) 将需求映射到模块架构, (5) 验证 PRD 格式合规性, (6) 验证竞品分析章节完整性。关键词:PRD分析, requirement extraction, KEP验证, completeness check, chapter order validation, 竞品分析检查, analyze PRD, 需求提取, 完整性检查, 章节顺序验证
development
基于 PRD 文档自动生成鸿蒙系统设计文档,包括架构设计文档和功能设计文档。生成前会分析 OpenHarmony 存量代码结构,确保与现有架构兼容。架构设计文档第2章必须为竞品方案分析,位于需求背景之后。适用于用户请求:(1) 生成架构设计文档, (2) 生成功能设计文档, (3) 从 PRD 生成设计文档, (4) 创建系统架构设计, (5) 编写功能规格说明, (6) 分析 OH 代码结构。关键词:architecture design, functional design, design doc, 竞品方案分析, OpenHarmony code analysis, 架构设计, 功能设计, 设计文档生成, OH代码分析, analyze codebase, competitor analysis