# AndroidScreenMatch **Repository Path**: yemesoft/android-screen-match ## Basic Information - **Project Name**: AndroidScreenMatch - **Description**: 零负担适配常用设备屏幕 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-29 - **Last Updated**: 2026-08-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Android Screen Match 屏幕适配方案 本项目采用基于 **Smallest Width (sw)** 的 Android 屏幕适配方案,通过脚本生成多套 dimens 资源,实现不同宽度设备的等比布局与字体适配。 按设计稿宽度提供 **4 个互斥模块**,按需二选一接入即可(不可同时依赖多个,否则 `dl_dp_*` 资源名冲突): | 模块 | 设计稿宽度 | 本地依赖 | 远程 artifact | |------|------------|----------|---------------| | `screenmatch1200` | **1200px** | `project(':screenmatch1200')` | `android-screen-match-1200` | | `screenmatch1080` | **1080px** | `project(':screenmatch1080')` | `android-screen-match-1080` | | `screenmatch750` | **750px** | `project(':screenmatch750')` | `android-screen-match-750` | | `screenmatch720` | **720px** | `project(':screenmatch720')` | `android-screen-match-720` | ## 快速开始 ### 方式一:模块依赖(推荐本地联调) ```groovy dependencies { // 按设计稿宽度四选一(示例为 1200) implementation project(':screenmatch1200') // implementation project(':screenmatch1080') // implementation project(':screenmatch750') // implementation project(':screenmatch720') } ``` ### 方式二:远程依赖(JitPack / Gitee) 根目录 `settings.gradle`(或旧版根 `build.gradle`)添加仓库: ```groovy dependencyResolutionManagement { repositories { google() mavenCentral() maven { url 'https://jitpack.io' } } } ``` 业务模块: ```groovy dependencies { // 按设计稿宽度选择其一 implementation 'com.gitee.yemesoft:android-screen-match-1200:1.8' // 1200 // implementation 'com.gitee.yemesoft:android-screen-match-1080:1.8' // 1080 // implementation 'com.gitee.yemesoft:android-screen-match-750:1.8' // 750 // implementation 'com.gitee.yemesoft:android-screen-match-720:1.8' // 720 } ``` > 各模块发布配置分别写在对应 `build.gradle`(`maven-publish`)。打 Tag `1.8` 后即可由 JitPack 构建。 ## 设计图尺寸与 Dimen 对应关系 **一句话总结:** 将设计图缩放到所选模块的设计宽度,标注尺寸 xxx,对应 `@dimen/dl_dp_xxx` / `@dimen/dl_sp_xxx`。 ### 转换示例(以 1200 模块、sw360dp 为例) | 设计图标注(1200px 宽度) | Dimen 引用 | 实际值(sw360dp) | |--------------------------|------------|-------------------| | 10px | `@dimen/dl_dp_10` | 3.00dp | | 20px | `@dimen/dl_dp_20` | 6.00dp | | 100px | `@dimen/dl_dp_100` | 30.00dp | | 200px | `@dimen/dl_dp_200` | 60.00dp | | -10px | `@dimen/dl_dp_m_10` | -3.00dp | | 28px(字体) | `@dimen/dl_sp_28` | 8.40sp | ### 各设计宽下同一标注的 sw360 对照 | 标注 xxx | 1200 模块 | 1080 模块 | 750 模块 | 720 模块 | |----------|-----------|-----------|----------|----------| | `dl_dp_10` | 3.00dp | 3.33dp | 4.80dp | 5.00dp | | `dl_dp_100` | 30.00dp | 33.33dp | 48.00dp | 50.00dp | | `dl_sp_28` | 8.40sp | 9.33sp | 13.44sp | 14.00sp | ### 在布局文件中使用 ```xml