Make an Android app display at correct proportions on phones with different screen sizes without custom code.
Override scaling rules for a specific Activity that needs different layout dimensions than the rest of the app.
Ensure both tablet and phone layouts look correct without maintaining separate layout files.
Use pt or mm measurement units in Android layouts as an alternative to dp for precise screen adaptation.
AndroidAutoSize is a library for Android app developers that solves the problem of apps looking different on phones with different screen sizes. Android phones come in hundreds of combinations of screen dimensions and pixel densities, and without special handling, a layout designed on one phone can look stretched, squished, or have wrong proportions on another. This library handles that problem automatically. The core idea is that during app development, designers typically create mockups at a fixed pixel size, such as 360 wide by 640 tall. AndroidAutoSize lets you declare those design dimensions in a single configuration file (the AndroidManifest.xml), and then the library adjusts how Android measures screen units at runtime so that every device shows your layout at the right proportions. You describe your layout in standard dp units, and the library takes care of the math. Setup requires only one step: adding two lines to your app manifest file with the design width and height. The library then activates automatically when the app starts. No other code changes are required for the basic case. For more complex situations, such as a specific screen that needs different scaling rules than the rest of the app, developers can implement an interface on individual Activities or Fragments to override the default values. Developers can also opt a specific screen out of adaptation entirely. The library supports additional measurement units (pt, in, mm) as alternatives to the default dp, which some developers prefer to avoid side effects of modifying Android internal display values. The project is open source under the Apache 2.0 license and supports Android API level 14 and above, meaning it works with virtually all Android devices in active use. The README includes screenshots comparing the layout on five different screen sizes, showing consistent results across all of them.
← jessyancoding on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.