explaingit

jessyancoding/androidautosize

13,739JavaAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

Android library that automatically makes your app look correct on any phone screen size by adjusting layout scaling at runtime, add two lines to your manifest and it activates with no other changes.

Mindmap

mindmap
  root((repo))
    What it does
      Fix screen scaling
      Adapt layouts at runtime
      Two-line setup
    Configuration
      Manifest declaration
      Design width and height
      API 14 and above
    Advanced Options
      Per-Activity overrides
      Opt-out specific screens
      Alt units pt mm
    Use Cases
      Multi-phone support
      Tablet scaling
      Consistent UI
    Audience
      Android developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Make an Android app display at correct proportions on phones with different screen sizes without custom code.

USE CASE 2

Override scaling rules for a specific Activity that needs different layout dimensions than the rest of the app.

USE CASE 3

Ensure both tablet and phone layouts look correct without maintaining separate layout files.

USE CASE 4

Use pt or mm measurement units in Android layouts as an alternative to dp for precise screen adaptation.

Tech stack

JavaKotlinAndroid

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose including commercial apps, as long as you keep the copyright notice.

In plain English

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.

Copy-paste prompts

Prompt 1
Add AndroidAutoSize to my Android project to fix layout scaling across different screen sizes, show me the two-line manifest setup.
Prompt 2
My Android app looks stretched on larger phones, how do I use AndroidAutoSize to fix proportions without changing my existing layouts?
Prompt 3
Show me how to override AndroidAutoSize for a single Activity that needs different design dimensions than the rest of my app.
Prompt 4
I am using Java in my Android project, how do I initialize AndroidAutoSize and configure it with a 375x812 design reference?
Prompt 5
How do I opt a specific screen out of AndroidAutoSize adaptation while keeping it active for the rest of the app?
Open on GitHub → Explain another repo

← jessyancoding on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.