{"id":19768565,"url":"https://github.com/wildma/screenadaptation","last_synced_at":"2025-05-16T00:06:35.242Z","repository":{"id":38238227,"uuid":"128288234","full_name":"wildma/ScreenAdaptation","owner":"wildma","description":":fire:一种非常好用的 Android 屏幕适配——smallestWidth 限定符适配 https://www.jianshu.com/p/1302ad5a4b04","archived":false,"fork":false,"pushed_at":"2021-10-17T07:53:18.000Z","size":634,"stargazers_count":1564,"open_issues_count":0,"forks_count":550,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-04-08T11:09:43.379Z","etag":null,"topics":["adaptation","adapterview","screen","screenadaptation"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wildma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-06T02:28:02.000Z","updated_at":"2025-04-03T01:03:36.000Z","dependencies_parsed_at":"2022-08-09T01:16:58.805Z","dependency_job_id":null,"html_url":"https://github.com/wildma/ScreenAdaptation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildma%2FScreenAdaptation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildma%2FScreenAdaptation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildma%2FScreenAdaptation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildma%2FScreenAdaptation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wildma","download_url":"https://codeload.github.com/wildma/ScreenAdaptation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442854,"owners_count":22071878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adaptation","adapterview","screen","screenadaptation"],"created_at":"2024-11-12T04:39:07.636Z","updated_at":"2025-05-16T00:06:33.399Z","avatar_url":"https://github.com/wildma.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 一种非常好用的 Android 屏幕适配——smallestWidth 限定符适配\n\n## 使用\n1. 获取设计图最小宽度（单位为 dp）。\n2. 以设计图最小宽度作为基准值，生成所有设备对应的 dimens.xml 文件。  \n如果项目只需要适配手机的话，只需要生成 320、360、362.2641、384、392.7272、400、410、411.4285、432、480 对应的 dimens.xml 文件即可。\n3. 根据设计图标注，标注多少 dp，布局中就写多少 dp，格式为 @dimen/dp_XX。\n\n详细介绍请看文章：[一种非常好用的 Android 屏幕适配](https://www.jianshu.com/p/1302ad5a4b04)\n\n## 优点\n- 使用简单  \n利用插件生成对应的 dimens.xml 文件，设计图标注多少 dp，布局中就写多少 dp，格式为 @dimen/dp_XX，sp 同理。\n\n- 稳定性好  \nsmallestWidth 限定符适配方案很早就出现了，经过大量用户的验证，市面上的主流设备几乎都能精准适配。\n\n- 对性能无影响  \n适配原理是系统根据限定符去寻找对应的 dimens.xml 文件，并不影响程序的性能。\n\n- 兼容性好  \nsmallestWidth 限定符适配寻找 dimens.xml 文件的原理是从大往小找，没有对应的则使用默认的，所以即使没有完全匹配也能达到不错的适配效果。\n\n- 不影响第三方库  \n需要适配的地方使用该种适配方案即可，不会影响到第三方库。\n\n- 更换成本低  \n该套适配方案采用的单位是 dp 和 sp，dp 和 sp 是 google 推荐使用的计量单位，即使以后不用该套适配方案，任然不影响现有的界面。\n\n\n## 适配效果图\n如下，将按钮的宽度设置为 @dimen/dp_360，运行在不同（最小宽度不同）的设备上都是可以铺满屏幕宽度的，说明适配成功！\n\n**Nexus S（320 dp）：**  \n\n![Nexus S](https://github.com/wildma/ScreenAdaptation/blob/master/screenshots/Nexus%20S.jpg)\n\n**Nexus 5（360 dp）：**  \n\n![Nexus 5](https://github.com/wildma/ScreenAdaptation/blob/master/screenshots/Nexus%205.jpg)\n\n**Nexus 4（384 dp）：**  \n\n![Nexus 4](https://github.com/wildma/ScreenAdaptation/blob/master/screenshots/Nexus%204.jpg)\n\n**Pixel 3（392.7272 dp）：**  \n\n![Pixel 3](https://github.com/wildma/ScreenAdaptation/blob/master/screenshots/Pixel%203.png)\n\n**Pixel XL（411.4285 dp）：**  \n\n![Pixel XL](https://github.com/wildma/ScreenAdaptation/blob/master/screenshots/Pixel%20XL.jpg)\n\n**Pixel 3 XL（411.4285 dp）：**  \n\n![Pixel 3 XL](https://github.com/wildma/ScreenAdaptation/blob/master/screenshots/Pixel%203%20XL.png)\n\n\nps：如果对你有帮助，点下 star 就是对我最大的认可。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwildma%2Fscreenadaptation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwildma%2Fscreenadaptation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwildma%2Fscreenadaptation/lists"}