JessYanCoding /AndroidAutoSize
🔥 A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案).
★ 13,725⑂ 2,002👁 195⑃ 8● 458▤ 14
+0
Daily
+0
Weekly
+5
Monthly
13,725
stars
2,002
forks
195
watchers
8
prs
458
issues
14
releases
README
!Logo
!Official
中文说明
A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案).
Overview
Pixel 2 XL | 1440 x 2880 | 560dpi:
Pixel XL | 1440 x 2560 | 560dpi:
Nexus 5X | 1080 x 1920 | 420dpi:
Nexus 4 | 768 x 1280 | 320dpi:
Nexus S | 480 x 800 | 240dpi:
Notice
Devices Info
Introduction Of Function
Framework Analysis
Common Issues
AndroidAutoLayout Migration Guide
Android Advanced Framework
Download
Jcenter ( ⚠️ DEPRECATION WARNING: the JCenter repository will keep serving packages until February 1st, 2022):
gradle
implementation 'me.jessyan:autosize:1.2.1'
JitPack:
Step 1. Add the JitPack repository in your root build.gradle at the end of repositories:
gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
gradle
dependencies {
implementation 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1'
}
Usage
Step 1 (just one steps)
Initialize in AndroidManifest, if you use a subunits, you can write the pixel size, no need to convert the pixel to dp, please see demo-subunits
xml
Preview
Real-time preview during layout is an important part of the development phase, in many cases, the default preview device provided by Android Studio does not fully display our design, so we need to create the virtual device ourselves, under the dp, pt, in, mm four units of virtual device creation method
If you don't want the status bar and navigation bar to appear in Preview during preview, you can select the panel theme according to the following image, after using this theme, the vertical resolution just fills the entire preview page
!theme
Virtual device creation method
!create step
DP
If you use dp as a unit in the layout file for layout (AndroidAutoSize supports dp, sp for layout by default), you can find the screen size according to the formula (sqrt(vertical resolution^2 + horizontal resolution^2))/dpi and create an virtual device (write screen size and resolution only)
!dp
PT
If you use pt as a unit in the layout file for layout (requires AutoSizeConfig.getInstance().getUnitsManager().setSupportSubunits(Subunits.PT); to open pt support), you can find the screen size according to the formula (sqrt(vertical resolution^2 + horizontal resolution^2))/72 and create an virtual device (write screen size and resolution only)
!pt
IN
If you use in as a unit in the layout file for layout (requires AutoSizeConfig.getInstance().getUnitsManager().setSupportSubunits(Subunits.IN); to open in support), you can find the screen size according to the formula sqrt(vertical resolution^2 + horizontal resolution^2) and create an virtual device (write screen size and resolution only)
!in
MM
If you use mm as a unit