JessYanCoding / AndroidAutoSize

🔥 A low-cost Android screen adaptation solution (今日头条屏幕适配方案终极版,一个极低成本的 Android 屏幕适配方案).
Apache License 2.0
13.47k stars 1.96k forks source link
adapterview android arms density mvparms screenadapter

Logo Official

Latest Stable Version Build Status Min Sdk Version License Author QQ Group

中文说明

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

Download

Jcenter ( ⚠️ DEPRECATION WARNING: the JCenter repository will keep serving packages until February 1st, 2022):

 implementation 'me.jessyan:autosize:1.2.1'

JitPack:

Step 1. Add the JitPack repository in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1'
}

Usage

Step 1 (just one steps)

Preview

DP

PT

IN

MM

Advance (see demo)

Activity

}


### Fragment
* **First enable the ability to support Fragment custom parameters**
```java
AutoSizeConfig.getInstance().setCustomFragment(true);

}


### Subunits (see demo-subunits)
* You can choose one of the three unpopular units of **pt, in, mm** as the subunits, the subunits is used to avoid the adverse effects caused by modifying **DisplayMetrics#density**, after using the subunits, you can write the pixel size on the design, you don't need to convert it to **dp**

```java
AutoSizeConfig.getInstance().getUnitsManager()
        .setSupportDP(false)
        .setSupportSP(false)
        .setSupportSubunits(Subunits.MM);

About Me

License

 Copyright 2018, jessyan

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.