@buaa_smat/hometrans 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -136
- package/agents/build-fixer.md +38 -48
- package/agents/code-reviewer.md +20 -20
- package/agents/logic-coder.md +8 -8
- package/agents/logic-context-builder.md +5 -5
- package/agents/review-fixer.md +16 -16
- package/agents/self-test-fixer.md +15 -15
- package/agents/self-tester.md +56 -55
- package/agents/spec-generator.md +16 -16
- package/dist/cli/config-store.js +120 -9
- package/dist/cli/config.js +4 -4
- package/dist/cli/env-vars.js +129 -0
- package/dist/cli/init.js +315 -276
- package/dist/cli/uninstall.js +152 -17
- package/dist/context/index.js +10 -197
- package/env-requirements.json +181 -181
- package/package.json +1 -1
- package/resource/choose_editor.png +0 -0
- package/resource/common_config.png +0 -0
- package/resource/integration_test_config.png +0 -0
- package/resource/migration_process.svg +94 -0
- package/resource/migration_process_transparent.svg +93 -0
- package/resource/set_env.png +0 -0
- package/resource/ui_align_config.png +0 -0
- package/skills/hmos-batch-ui-align/SKILL.md +10 -0
- package/skills/hmos-batch-ui-align/references/conversion-procedure.md +180 -180
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-batch-ui-align/references/mvvm/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-batch-ui-align/references/mvvm/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-batch-ui-align/references/mvvm/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-batch-ui-align/references/mvvm/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-batch-ui-align/references/mvvm/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-batch-ui-align/references/mvvm/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-batch-ui-align/references/mvvm/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-batch-ui-align/references/mvvm/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-batch-ui-align/references/mvvm/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-batch-ui-align/references/mvvm/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-batch-ui-align/references/mvvm/MVVM/346/250/241/345/274/217/357/274/210V1/357/274/211.md +911 -911
- package/skills/hmos-batch-ui-align/references/mvvm/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-batch-ui-align/references/mvvm//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-convert-pipeline/SKILL.md +63 -49
- package/skills/hmos-fix-build-errors/SKILL.md +5 -6
- package/skills/hmos-fix-build-errors/references/arkts-strict-patterns.md +219 -219
- package/skills/hmos-fix-build-errors/references/known-patterns.md +157 -157
- package/skills/hmos-fix-build-errors/references/rdb-entity-pattern.md +131 -131
- package/skills/hmos-incremental-ui-align/{readme.md → README.md} +28 -21
- package/skills/hmos-incremental-ui-align/SKILL.md +46 -27
- package/skills/hmos-incremental-ui-align/diff_analysis.md +52 -52
- package/skills/hmos-incremental-ui-align/page_align.md +62 -62
- package/skills/hmos-incremental-ui-align/references/Comparison_Template.md +2 -2
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Link/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/217/214/345/220/221/345/220/214/346/255/245.md +648 -648
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Observed/350/243/205/351/245/260/345/231/250/345/222/214@ObjectLink/350/243/205/351/245/260/345/231/250/357/274/232/345/265/214/345/245/227/347/261/273/345/257/271/350/261/241/345/261/236/346/200/247/345/217/230/345/214/226.md +2088 -2088
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Prop/350/243/205/351/245/260/345/231/250/357/274/232/347/210/266/345/255/220/345/215/225/345/220/221/345/220/214/346/255/245.md +1033 -1033
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Provide/350/243/205/351/245/260/345/231/250/345/222/214@Consume/350/243/205/351/245/260/345/231/250/357/274/232/344/270/216/345/220/216/344/273/243/347/273/204/344/273/266/345/217/214/345/220/221/345/220/214/346/255/245.md +1183 -1183
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@State/350/243/205/351/245/260/345/231/250/357/274/232/347/273/204/344/273/266/345/206/205/347/212/266/346/200/201.md +576 -576
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Track/350/243/205/351/245/260/345/231/250/357/274/232class/345/257/271/350/261/241/345/261/236/346/200/247/347/272/247/346/233/264/346/226/260.md +297 -297
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/@Watch/350/243/205/351/245/260/345/231/250/357/274/232/347/212/266/346/200/201/345/217/230/351/207/217/346/233/264/346/224/271/351/200/232/347/237/245.md +395 -395
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/AppStorage/357/274/232/345/272/224/347/224/250/345/205/250/345/261/200/347/232/204UI/347/212/266/346/200/201/345/255/230/345/202/250.md +902 -902
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/Environment/357/274/232/350/256/276/345/244/207/347/216/257/345/242/203/346/237/245/350/257/242.md +106 -106
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/LocalStorage/357/274/232/351/241/265/351/235/242/347/272/247UI/347/212/266/346/200/201/345/255/230/345/202/250.md +1178 -1178
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/MVVM/346/250/241/345/274/217V1.md +911 -911
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243/PersistentStorage/357/274/232/346/214/201/344/271/205/345/214/226/345/255/230/345/202/250UI/347/212/266/346/200/201.md +354 -354
- package/skills/hmos-incremental-ui-align/references/MVVM/345/274/200/345/217/221/346/226/207/346/241/243//347/256/241/347/220/206/345/272/224/347/224/250/346/213/245/346/234/211/347/232/204/347/212/266/346/200/201/346/246/202/350/277/260.md +11 -11
- package/skills/hmos-incremental-ui-align/references/UI_Analysis_Template.md +3 -3
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2533 -2533
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-interaction-mapping-reference.md +555 -555
- package/skills/hmos-incremental-ui-align/references/android-to-harmonyOS-ui-layout-mapping-reference.md +117 -117
- package/skills/hmos-incremental-ui-align/scripts/navigation-capure.md +37 -37
- package/skills/hmos-integration-test/{readme.md → README.md} +38 -38
- package/skills/hmos-integration-test/SKILL.md +63 -52
- package/skills/hmos-resources-convert/SKILL.md +5 -5
- package/skills/hmos-resources-convert/references/conversion-rules.md +663 -663
- package/skills/hmos-resources-convert/references/dependency-analysis-rules.md +388 -388
- package/skills/hmos-resources-convert/references/resource-mapping-rules.md +457 -457
- package/skills/hmos-resources-convert/references/xml-drawable-to-svg-rules.md +513 -513
- package/skills/hmos-spec-generate/SKILL.md +19 -19
- package/skills/hmos-spec-generate/references/android-platform-tokens.md +105 -105
- package/skills/hmos-spec-generate/references/spec-sample-1.md +78 -78
- package/skills/hmos-spec-generate/references/spec-sample-2.md +58 -58
- package/skills/hmos-spec-generate/references/spec-sample-3.md +116 -116
- package/skills/hmos-spec-generate/references/step4-report-template.md +33 -33
- package/tools/test-tools/autotest/README.md +33 -17
- package/tools/test-tools/autotest/self_test_runner.py +109 -15
- package/resource/hometrans_config.png +0 -0
- package/skills/hmos-incremental-ui-align/config-example.json +0 -11
- package/tools/test-tools/autotest/config.yaml.example +0 -58
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
# Android-to-HarmonyOS UI Layout Mapping Reference
|
|
2
|
-
|
|
3
|
-
<!-- TODO: Fill in the actual UI layout mapping content -->
|
|
4
|
-
<!-- This reference maps Android layout containers to HarmonyOS ArkUI layout equivalents -->
|
|
5
|
-
<!-- Covers: LinearLayout→Column/Row, FrameLayout→Stack, ConstraintLayout→RelativeContainer, RecyclerView→List+LazyForEach, ScrollView→Scroll, etc. -->
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
## 布局容器映射
|
|
9
|
-
|
|
10
|
-
| 安卓部分UI | 对应鸿蒙部分UI | 其他说明 |
|
|
11
|
-
|-----------|---------------|---------|
|
|
12
|
-
| `LinearLayout` (vertical) | `Column` 组件 | 纵向线性布局,支持 `.justifyContent()`、`.alignItems()` |
|
|
13
|
-
| `LinearLayout` (horizontal) | `Row` 组件 | 横向线性布局 |
|
|
14
|
-
| `FrameLayout` | `Stack` 组件 | 层叠布局,支持 `.alignContent()` |
|
|
15
|
-
| `RelativeLayout` | `RelativeContainer` 组件 | 相对布局,通过 `.alignRules()` 设置定位规则 |
|
|
16
|
-
| `ConstraintLayout` | `RelativeContainer` / 自定义布局 | 约束布局,复杂场景可用自定义 `onMeasureSize`/`onPlaceChildren` |
|
|
17
|
-
| `FlexboxLayout` | `Flex` 组件 | 弹性布局,支持 `FlexDirection`/`FlexWrap`/`FlexAlign` 标准 Flexbox |
|
|
18
|
-
| `GridLayout` | `Grid` 组件 | 网格布局,通过 `.columnsTemplate('1fr 1fr 1fr')` 定义列 |
|
|
19
|
-
| `TableLayout` | `Grid` 组件 | 表格布局,使用 `Grid` 组件模拟表格结构 |
|
|
20
|
-
| `CoordinatorLayout` | 组合 `Scroll` + `Column` + 动画 | 无直接对应,需组合模拟 AppBar 折叠效果 |
|
|
21
|
-
| `AppBarLayout` / `CollapsingToolbarLayout` | `Navigation` 标题栏 + `titleMode` | 折叠工具栏,`NavigationTitleMode.Full`→`.Mini` 自动切换 |
|
|
22
|
-
| `ScrollView` | `Scroll` 组件 | 滚动容器,通过 `Scroller` 控制器编程式滚动 |
|
|
23
|
-
| `HorizontalScrollView` | `Scroll` + `ScrollDirection.Horizontal` | 横向滚动 |
|
|
24
|
-
| `NestedScrollView` | `Scroll` + `.nestedScroll()` | 嵌套滚动策略配置 |
|
|
25
|
-
| `ViewPager` / `ViewPager2` | `Swiper` 组件 | 页面滑动切换,支持 `.autoPlay()`、`.indicator()`、`.loop()` |
|
|
26
|
-
| `SwipeRefreshLayout` | `Refresh` 组件 | 下拉刷新,通过 `.onRefreshing()` 回调处理刷新 |
|
|
27
|
-
| `RecyclerView` | `List` 组件 | 高性能列表,使用 `List` + `ForEach`/`LazyForEach` 渲染子组件 |
|
|
28
|
-
| `RecyclerView` (GridLayoutManager) | `Grid` 组件 | 网格布局,通过 `.columnsTemplate()` 设置列数 |
|
|
29
|
-
| `RecyclerView` (StaggeredGridLayoutManager) | `WaterFlow` 组件 | 瀑布流布局 |
|
|
30
|
-
| `ListView` | `List` 组件 | 传统列表,使用 `List` 组件实现 |
|
|
31
|
-
| `GridView` | `Grid` 组件 | 网格视图,使用 `Grid` 组件实现 |
|
|
32
|
-
| `DrawerLayout` / `NavigationView` | `SideBarContainer` 组件 | 侧边栏/抽屉 |
|
|
33
|
-
| `TabLayout` + `ViewPager` | `Tabs` 组件 | 标签页,`Tabs` 整合标签栏和内容页切换 |
|
|
34
|
-
| `BottomNavigationView` | `Tabs` + `BarPosition.End` | 底部导航栏 |
|
|
35
|
-
| `CardView` | `Card` 组件 / `Container` + 样式 | 卡片视图,使用 `Card` 组件或自定义样式实现 |
|
|
36
|
-
| `Space` | `Blank` 组件 | 空白间隔,使用 `Blank` 组件实现 |
|
|
37
|
-
| `FragmentContainerView` | `NavDestination` / `@Component` | 片段容器视图,映射到 `NavDestination` 或自定义组件 |
|
|
38
|
-
| `RecyclerViewFastScroller` | 自定义组件 | 列表快速滚动条,需自定义实现 |
|
|
39
|
-
| `MySearchMenu` (自定义) | `Search` 组件 + 自定义菜单 | 自定义搜索菜单,使用 `Search` 组件并添加自定义菜单 |
|
|
40
|
-
| `MyViewPager` (自定义) | `Swiper` 组件 | 自定义视图分页器,使用 `Swiper` 组件实现 |
|
|
41
|
-
| `MyRecyclerView` (自定义) | `List` 组件 | 自定义 RecyclerView,使用 `List` 组件实现 |
|
|
42
|
-
| `MyTextView` (自定义) | `Text` 组件 | 自定义 TextView,使用 `Text` 组件实现 |
|
|
43
|
-
| `MyAppCompatCheckbox` (自定义) | `Checkbox` 组件 | 自定义 Checkbox,使用 `Checkbox` 组件实现 |
|
|
44
|
-
|
|
45
|
-
## 布局属性映射
|
|
46
|
-
|
|
47
|
-
| 安卓部分UI | 对应鸿蒙部分UI | 其他说明 |
|
|
48
|
-
|-----------|---------------|---------|
|
|
49
|
-
| `layout_weight` | `.layoutWeight()` / `.flexGrow()` | 权重分配 |
|
|
50
|
-
| `padding` / `margin` | `.padding()` / `.margin()` | 支持统一或分别指定 `{ top, right, bottom, left }` |
|
|
51
|
-
| `View.GONE` / `View.INVISIBLE` | `Visibility.None` / `Visibility.Hidden` | `None`=不占位(GONE);`Hidden`=占位不显示(INVISIBLE) |
|
|
52
|
-
| `android:id` | `.id('xxx')` / 组件引用变量 | 组件标识 |
|
|
53
|
-
| `android:background` | `.backgroundColor()` / `.backgroundImage()` | 背景 |
|
|
54
|
-
| `android:alpha` | `.opacity()` | 透明度 0~1 |
|
|
55
|
-
| `android:elevation` | `.shadow({ radius, color, offsetX, offsetY })` | 阴影 |
|
|
56
|
-
| `android:rotation` | `.rotate({ angle: xxx })` | 旋转 |
|
|
57
|
-
| `android:scaleX/Y` | `.scale({ x: xxx, y: xxx })` | 缩放 |
|
|
58
|
-
| `android:translationX/Y` | `.translate({ x: xxx, y: xxx })` | 平移 |
|
|
59
|
-
| `android:clipToOutline` | `.clip(true)` / `.clipShape()` | 裁剪 |
|
|
60
|
-
| `setEnabled(false)` | `.enabled(false)` | 禁用状态 |
|
|
61
|
-
| `android:focusable` | `.focusable(true)` | 可聚焦 |
|
|
62
|
-
| `android:focusableInTouchMode` | `.focusable(true)` + `.focusOnTouch(true)` | 触摸模式下可聚焦 |
|
|
63
|
-
| `android:clickable` | `.enabled(true)` + `.onClick()` | 可点击 |
|
|
64
|
-
| `android:longClickable` | `.gesture(LongPressGesture())` | 可长按 |
|
|
65
|
-
| `android:scrollbars` | `.scrollBar()` | 滚动条 |
|
|
66
|
-
| `android:fadeScrollbars` | `.scrollBar().fade(true)` | 滚动条自动隐藏 |
|
|
67
|
-
| `android:overScrollMode` | `.overScrollMode()` | 过度滚动模式 |
|
|
68
|
-
| `GradientDrawable` | `.linearGradient()` / `.radialGradient()` | 渐变背景 |
|
|
69
|
-
| `CardView` radius | `.borderRadius()` | 圆角 |
|
|
70
|
-
| `GradientDrawable.setStroke()` | `.border({ width, color, radius })` | 边框 |
|
|
71
|
-
| `android:layout_width` / `android:layout_height` | `.width()` / `.height()` | 宽高设置,支持具体数值、百分比、`'match_parent'`/`'wrap_content'` |
|
|
72
|
-
| `android:gravity` | `.alignItems()` / `.justifyContent()` | 内容对齐方式 |
|
|
73
|
-
| `android:layout_gravity` | `.alignSelf()` | 子组件在父容器中的对齐方式 |
|
|
74
|
-
| `android:orientation` (LinearLayout) | `Column` / `Row` | 布局方向 |
|
|
75
|
-
| `android:divider` (LinearLayout) | `Divider` 组件 | 分隔线 |
|
|
76
|
-
| `android:showDividers` (LinearLayout) | `Divider` 组件位置 | 分隔线显示位置 |
|
|
77
|
-
|
|
78
|
-
## 页面结构映射
|
|
79
|
-
|
|
80
|
-
| 安卓部分UI | 对应鸿蒙部分UI | 其他说明 |
|
|
81
|
-
|-----------|---------------|---------|
|
|
82
|
-
| `Activity` | `PageAbility` | 主UI容器 |
|
|
83
|
-
| `Fragment` | `NavDestination` / `@Component` | 通过 Navigation + NavDestination 实现子页面路由 |
|
|
84
|
-
| `Service` | `ServiceAbility` | 后台服务 |
|
|
85
|
-
| `BroadcastReceiver` | `EventHub` + `@Event` | 广播接收器,使用事件订阅机制 |
|
|
86
|
-
| `ContentProvider` | `DataAbility` | 内容提供者 |
|
|
87
|
-
| `Toolbar` / `ActionBar` | `Navigation` 标题栏 | 通过 `.title()` 和 `.menus()` 配置 |
|
|
88
|
-
| `Intent` | `router` 模块 | 页面导航,使用 `router.push()`、`router.replace()` 等 |
|
|
89
|
-
| `Bundle` | `router.push({ params: {} })` | 页面间传递数据 |
|
|
90
|
-
| `onActivityResult` | `router.push()` + 回调 | 页面返回结果 |
|
|
91
|
-
| `startActivityForResult` | `router.push()` + 回调 | 启动页面并获取结果 |
|
|
92
|
-
|
|
93
|
-
## 列表与可滚动组件映射
|
|
94
|
-
|
|
95
|
-
| 安卓部分UI | 对应鸿蒙部分UI | 其他说明 |
|
|
96
|
-
|-----------|---------------|---------|
|
|
97
|
-
| `RecyclerView.Adapter` | `LazyForEach` + `IDataSource` | 数据适配器,实现 `IDataSource` 接口配合 `LazyForEach` 懒加载 |
|
|
98
|
-
| `RecyclerView.ViewHolder` | `@Builder` / `@Component` | 声明式 UI 无需 ViewHolder 模式 |
|
|
99
|
-
| `LinearLayoutManager` | `List` 默认布局 | 纵向列表,`.listDirection(Axis.Horizontal)` 切换横向 |
|
|
100
|
-
| `GridLayoutManager` | `Grid` 组件 | 网格布局管理器 |
|
|
101
|
-
| `StaggeredGridLayoutManager` | `WaterFlow` 组件 | 瀑布流布局管理器 |
|
|
102
|
-
| `ItemTouchHelper` (swipe) | `ListItem.swipeAction()` | 列表项滑动操作菜单 |
|
|
103
|
-
| `ItemTouchHelper` (drag) | `ListItem.dragable()` | 列表项拖拽排序 |
|
|
104
|
-
| `DiffUtil` | `IDataSource` 的 `DataChangeListener` | 差异通知,`onDataAdd`/`onDataDelete`/`onDataChange` |
|
|
105
|
-
| `PagerAdapter` / `FragmentStateAdapter` | `Swiper` + `ForEach`/`LazyForEach` | 无需 Adapter 模式,直接循环渲染子页面 |
|
|
106
|
-
| `ListAdapter` | `LazyForEach` + `IDataSource` | 带 DiffUtil 的适配器 |
|
|
107
|
-
| `ArrayAdapter` | `ForEach` + 数组 | 数组适配器 |
|
|
108
|
-
| `BaseAdapter` | `ForEach` / `LazyForEach` | 基础适配器 |
|
|
109
|
-
|
|
110
|
-
## 迁移注意事项
|
|
111
|
-
|
|
112
|
-
1. **范式转换**:Android 使用命令式 UI(XML 布局 + Java/Kotlin 操作);ArkUI 使用声明式 UI(ArkTS 组件树 + 状态驱动渲染)
|
|
113
|
-
2. **Adapter 模式消除**:`RecyclerView.Adapter`、`PagerAdapter` 等被 `ForEach`/`LazyForEach` + `IDataSource` 替代
|
|
114
|
-
3. **Fragment → NavDestination**:Fragment 模块化 UI 能力映射到 `Navigation` + `NavDestination` 路由
|
|
115
|
-
4. **布局属性调整**:Android 的布局属性需要转换为 ArkUI 的链式调用语法
|
|
116
|
-
5. **性能优化**:使用 `LazyForEach` 进行懒加载,避免一次性渲染大量数据
|
|
117
|
-
6. **响应式布局**:使用 `Flex` 和 `Grid` 组件实现响应式布局,适应不同屏幕尺寸
|
|
1
|
+
# Android-to-HarmonyOS UI Layout Mapping Reference
|
|
2
|
+
|
|
3
|
+
<!-- TODO: Fill in the actual UI layout mapping content -->
|
|
4
|
+
<!-- This reference maps Android layout containers to HarmonyOS ArkUI layout equivalents -->
|
|
5
|
+
<!-- Covers: LinearLayout→Column/Row, FrameLayout→Stack, ConstraintLayout→RelativeContainer, RecyclerView→List+LazyForEach, ScrollView→Scroll, etc. -->
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
## 布局容器映射
|
|
9
|
+
|
|
10
|
+
| 安卓部分UI | 对应鸿蒙部分UI | 其他说明 |
|
|
11
|
+
|-----------|---------------|---------|
|
|
12
|
+
| `LinearLayout` (vertical) | `Column` 组件 | 纵向线性布局,支持 `.justifyContent()`、`.alignItems()` |
|
|
13
|
+
| `LinearLayout` (horizontal) | `Row` 组件 | 横向线性布局 |
|
|
14
|
+
| `FrameLayout` | `Stack` 组件 | 层叠布局,支持 `.alignContent()` |
|
|
15
|
+
| `RelativeLayout` | `RelativeContainer` 组件 | 相对布局,通过 `.alignRules()` 设置定位规则 |
|
|
16
|
+
| `ConstraintLayout` | `RelativeContainer` / 自定义布局 | 约束布局,复杂场景可用自定义 `onMeasureSize`/`onPlaceChildren` |
|
|
17
|
+
| `FlexboxLayout` | `Flex` 组件 | 弹性布局,支持 `FlexDirection`/`FlexWrap`/`FlexAlign` 标准 Flexbox |
|
|
18
|
+
| `GridLayout` | `Grid` 组件 | 网格布局,通过 `.columnsTemplate('1fr 1fr 1fr')` 定义列 |
|
|
19
|
+
| `TableLayout` | `Grid` 组件 | 表格布局,使用 `Grid` 组件模拟表格结构 |
|
|
20
|
+
| `CoordinatorLayout` | 组合 `Scroll` + `Column` + 动画 | 无直接对应,需组合模拟 AppBar 折叠效果 |
|
|
21
|
+
| `AppBarLayout` / `CollapsingToolbarLayout` | `Navigation` 标题栏 + `titleMode` | 折叠工具栏,`NavigationTitleMode.Full`→`.Mini` 自动切换 |
|
|
22
|
+
| `ScrollView` | `Scroll` 组件 | 滚动容器,通过 `Scroller` 控制器编程式滚动 |
|
|
23
|
+
| `HorizontalScrollView` | `Scroll` + `ScrollDirection.Horizontal` | 横向滚动 |
|
|
24
|
+
| `NestedScrollView` | `Scroll` + `.nestedScroll()` | 嵌套滚动策略配置 |
|
|
25
|
+
| `ViewPager` / `ViewPager2` | `Swiper` 组件 | 页面滑动切换,支持 `.autoPlay()`、`.indicator()`、`.loop()` |
|
|
26
|
+
| `SwipeRefreshLayout` | `Refresh` 组件 | 下拉刷新,通过 `.onRefreshing()` 回调处理刷新 |
|
|
27
|
+
| `RecyclerView` | `List` 组件 | 高性能列表,使用 `List` + `ForEach`/`LazyForEach` 渲染子组件 |
|
|
28
|
+
| `RecyclerView` (GridLayoutManager) | `Grid` 组件 | 网格布局,通过 `.columnsTemplate()` 设置列数 |
|
|
29
|
+
| `RecyclerView` (StaggeredGridLayoutManager) | `WaterFlow` 组件 | 瀑布流布局 |
|
|
30
|
+
| `ListView` | `List` 组件 | 传统列表,使用 `List` 组件实现 |
|
|
31
|
+
| `GridView` | `Grid` 组件 | 网格视图,使用 `Grid` 组件实现 |
|
|
32
|
+
| `DrawerLayout` / `NavigationView` | `SideBarContainer` 组件 | 侧边栏/抽屉 |
|
|
33
|
+
| `TabLayout` + `ViewPager` | `Tabs` 组件 | 标签页,`Tabs` 整合标签栏和内容页切换 |
|
|
34
|
+
| `BottomNavigationView` | `Tabs` + `BarPosition.End` | 底部导航栏 |
|
|
35
|
+
| `CardView` | `Card` 组件 / `Container` + 样式 | 卡片视图,使用 `Card` 组件或自定义样式实现 |
|
|
36
|
+
| `Space` | `Blank` 组件 | 空白间隔,使用 `Blank` 组件实现 |
|
|
37
|
+
| `FragmentContainerView` | `NavDestination` / `@Component` | 片段容器视图,映射到 `NavDestination` 或自定义组件 |
|
|
38
|
+
| `RecyclerViewFastScroller` | 自定义组件 | 列表快速滚动条,需自定义实现 |
|
|
39
|
+
| `MySearchMenu` (自定义) | `Search` 组件 + 自定义菜单 | 自定义搜索菜单,使用 `Search` 组件并添加自定义菜单 |
|
|
40
|
+
| `MyViewPager` (自定义) | `Swiper` 组件 | 自定义视图分页器,使用 `Swiper` 组件实现 |
|
|
41
|
+
| `MyRecyclerView` (自定义) | `List` 组件 | 自定义 RecyclerView,使用 `List` 组件实现 |
|
|
42
|
+
| `MyTextView` (自定义) | `Text` 组件 | 自定义 TextView,使用 `Text` 组件实现 |
|
|
43
|
+
| `MyAppCompatCheckbox` (自定义) | `Checkbox` 组件 | 自定义 Checkbox,使用 `Checkbox` 组件实现 |
|
|
44
|
+
|
|
45
|
+
## 布局属性映射
|
|
46
|
+
|
|
47
|
+
| 安卓部分UI | 对应鸿蒙部分UI | 其他说明 |
|
|
48
|
+
|-----------|---------------|---------|
|
|
49
|
+
| `layout_weight` | `.layoutWeight()` / `.flexGrow()` | 权重分配 |
|
|
50
|
+
| `padding` / `margin` | `.padding()` / `.margin()` | 支持统一或分别指定 `{ top, right, bottom, left }` |
|
|
51
|
+
| `View.GONE` / `View.INVISIBLE` | `Visibility.None` / `Visibility.Hidden` | `None`=不占位(GONE);`Hidden`=占位不显示(INVISIBLE) |
|
|
52
|
+
| `android:id` | `.id('xxx')` / 组件引用变量 | 组件标识 |
|
|
53
|
+
| `android:background` | `.backgroundColor()` / `.backgroundImage()` | 背景 |
|
|
54
|
+
| `android:alpha` | `.opacity()` | 透明度 0~1 |
|
|
55
|
+
| `android:elevation` | `.shadow({ radius, color, offsetX, offsetY })` | 阴影 |
|
|
56
|
+
| `android:rotation` | `.rotate({ angle: xxx })` | 旋转 |
|
|
57
|
+
| `android:scaleX/Y` | `.scale({ x: xxx, y: xxx })` | 缩放 |
|
|
58
|
+
| `android:translationX/Y` | `.translate({ x: xxx, y: xxx })` | 平移 |
|
|
59
|
+
| `android:clipToOutline` | `.clip(true)` / `.clipShape()` | 裁剪 |
|
|
60
|
+
| `setEnabled(false)` | `.enabled(false)` | 禁用状态 |
|
|
61
|
+
| `android:focusable` | `.focusable(true)` | 可聚焦 |
|
|
62
|
+
| `android:focusableInTouchMode` | `.focusable(true)` + `.focusOnTouch(true)` | 触摸模式下可聚焦 |
|
|
63
|
+
| `android:clickable` | `.enabled(true)` + `.onClick()` | 可点击 |
|
|
64
|
+
| `android:longClickable` | `.gesture(LongPressGesture())` | 可长按 |
|
|
65
|
+
| `android:scrollbars` | `.scrollBar()` | 滚动条 |
|
|
66
|
+
| `android:fadeScrollbars` | `.scrollBar().fade(true)` | 滚动条自动隐藏 |
|
|
67
|
+
| `android:overScrollMode` | `.overScrollMode()` | 过度滚动模式 |
|
|
68
|
+
| `GradientDrawable` | `.linearGradient()` / `.radialGradient()` | 渐变背景 |
|
|
69
|
+
| `CardView` radius | `.borderRadius()` | 圆角 |
|
|
70
|
+
| `GradientDrawable.setStroke()` | `.border({ width, color, radius })` | 边框 |
|
|
71
|
+
| `android:layout_width` / `android:layout_height` | `.width()` / `.height()` | 宽高设置,支持具体数值、百分比、`'match_parent'`/`'wrap_content'` |
|
|
72
|
+
| `android:gravity` | `.alignItems()` / `.justifyContent()` | 内容对齐方式 |
|
|
73
|
+
| `android:layout_gravity` | `.alignSelf()` | 子组件在父容器中的对齐方式 |
|
|
74
|
+
| `android:orientation` (LinearLayout) | `Column` / `Row` | 布局方向 |
|
|
75
|
+
| `android:divider` (LinearLayout) | `Divider` 组件 | 分隔线 |
|
|
76
|
+
| `android:showDividers` (LinearLayout) | `Divider` 组件位置 | 分隔线显示位置 |
|
|
77
|
+
|
|
78
|
+
## 页面结构映射
|
|
79
|
+
|
|
80
|
+
| 安卓部分UI | 对应鸿蒙部分UI | 其他说明 |
|
|
81
|
+
|-----------|---------------|---------|
|
|
82
|
+
| `Activity` | `PageAbility` | 主UI容器 |
|
|
83
|
+
| `Fragment` | `NavDestination` / `@Component` | 通过 Navigation + NavDestination 实现子页面路由 |
|
|
84
|
+
| `Service` | `ServiceAbility` | 后台服务 |
|
|
85
|
+
| `BroadcastReceiver` | `EventHub` + `@Event` | 广播接收器,使用事件订阅机制 |
|
|
86
|
+
| `ContentProvider` | `DataAbility` | 内容提供者 |
|
|
87
|
+
| `Toolbar` / `ActionBar` | `Navigation` 标题栏 | 通过 `.title()` 和 `.menus()` 配置 |
|
|
88
|
+
| `Intent` | `router` 模块 | 页面导航,使用 `router.push()`、`router.replace()` 等 |
|
|
89
|
+
| `Bundle` | `router.push({ params: {} })` | 页面间传递数据 |
|
|
90
|
+
| `onActivityResult` | `router.push()` + 回调 | 页面返回结果 |
|
|
91
|
+
| `startActivityForResult` | `router.push()` + 回调 | 启动页面并获取结果 |
|
|
92
|
+
|
|
93
|
+
## 列表与可滚动组件映射
|
|
94
|
+
|
|
95
|
+
| 安卓部分UI | 对应鸿蒙部分UI | 其他说明 |
|
|
96
|
+
|-----------|---------------|---------|
|
|
97
|
+
| `RecyclerView.Adapter` | `LazyForEach` + `IDataSource` | 数据适配器,实现 `IDataSource` 接口配合 `LazyForEach` 懒加载 |
|
|
98
|
+
| `RecyclerView.ViewHolder` | `@Builder` / `@Component` | 声明式 UI 无需 ViewHolder 模式 |
|
|
99
|
+
| `LinearLayoutManager` | `List` 默认布局 | 纵向列表,`.listDirection(Axis.Horizontal)` 切换横向 |
|
|
100
|
+
| `GridLayoutManager` | `Grid` 组件 | 网格布局管理器 |
|
|
101
|
+
| `StaggeredGridLayoutManager` | `WaterFlow` 组件 | 瀑布流布局管理器 |
|
|
102
|
+
| `ItemTouchHelper` (swipe) | `ListItem.swipeAction()` | 列表项滑动操作菜单 |
|
|
103
|
+
| `ItemTouchHelper` (drag) | `ListItem.dragable()` | 列表项拖拽排序 |
|
|
104
|
+
| `DiffUtil` | `IDataSource` 的 `DataChangeListener` | 差异通知,`onDataAdd`/`onDataDelete`/`onDataChange` |
|
|
105
|
+
| `PagerAdapter` / `FragmentStateAdapter` | `Swiper` + `ForEach`/`LazyForEach` | 无需 Adapter 模式,直接循环渲染子页面 |
|
|
106
|
+
| `ListAdapter` | `LazyForEach` + `IDataSource` | 带 DiffUtil 的适配器 |
|
|
107
|
+
| `ArrayAdapter` | `ForEach` + 数组 | 数组适配器 |
|
|
108
|
+
| `BaseAdapter` | `ForEach` / `LazyForEach` | 基础适配器 |
|
|
109
|
+
|
|
110
|
+
## 迁移注意事项
|
|
111
|
+
|
|
112
|
+
1. **范式转换**:Android 使用命令式 UI(XML 布局 + Java/Kotlin 操作);ArkUI 使用声明式 UI(ArkTS 组件树 + 状态驱动渲染)
|
|
113
|
+
2. **Adapter 模式消除**:`RecyclerView.Adapter`、`PagerAdapter` 等被 `ForEach`/`LazyForEach` + `IDataSource` 替代
|
|
114
|
+
3. **Fragment → NavDestination**:Fragment 模块化 UI 能力映射到 `Navigation` + `NavDestination` 路由
|
|
115
|
+
4. **布局属性调整**:Android 的布局属性需要转换为 ArkUI 的链式调用语法
|
|
116
|
+
5. **性能优化**:使用 `LazyForEach` 进行懒加载,避免一次性渲染大量数据
|
|
117
|
+
6. **响应式布局**:使用 `Flex` 和 `Grid` 组件实现响应式布局,适应不同屏幕尺寸
|