/ Layout

A low-cost Android screen adaptation solution

A low-cost Android screen adaptation solution

AndroidAutoSize

A low-cost Android screen adaptation solution.

Overview

Pixel 2 XL | 1440 x 2880 | 560dpi:

Pixel-2-XL

Pixel XL | 1440 x 2560 | 560dpi:

Pixel-XL-v

Nexus 5X | 1080 x 1920 | 420dpi:

Nexus-5X

Nexus 4 | 768 x 1280 | 320dpi:

Nexus-4

Nexus S | 480 x 800 | 240dpi:

Nexus-S

Download

 implementation 'me.jessyan:autosize:0.7.0'

Usage (just one steps)

Step 1

  • Initialize in AndroidManifest:
<manifest>
    <application>            
        <meta-data
            android:name="design_width_in_dp"
            android:value="360"/>
        <meta-data
            android:name="design_height_in_dp"
            android:value="640"/>           
     </application>           
</manifest>

Advance (see demo)

  • Customize the adaptation parameters of the Activity:
public class CustomAdaptActivity extends AppCompatActivity implements CustomAdapt {

    @Override
    public boolean isBaseOnWidth() {
        return false;
    }

    @Override
    public float getSizeInDp() {
        return 667;
    }
}

  • Cancel the adaptation of the Activity:
public class CancelAdaptActivity extends AppCompatActivity implements CancelAdapt {

}

ProGuard

 -keep class me.jessyan.autosize.** { *; }
 -keep interface me.jessyan.autosize.** { *; }

GitHub