Skip to content

Dynamically auto adjust the sizes of dimension supporting multiple screens sizes.

Notifications You must be signed in to change notification settings

aman-jham/AutoAdjustDimens

Repository files navigation

Logo

Auto Adjust Scalable Dimension Library

Platform API


Twitter Codacy Badge

This is an Android library allowing to auto adjust the density and scale pixels.

USAGE

To use this library in your project Using Android Studio and Gradle:

implementation 'com.auto.adjust:dimens:1.0.9'

XML

android:layout_width="@dimen/_100adp"
         
android:layout_height="@dimen/_100adp"
         
android:padding="@dimen/_8adp"
         
android:margin="@dimen/_8adp"

android:textSize="@dimen/_11asp"

You must use the following properties in your XML.

Properties Descriptions
@dimen/_100adp For positive dimens
@dimen/_100_minus_adp For negative dimens
@dimen/_11asp For text sizes

KOTLIN

resources.getDimensionPixelSize(R.dimen._100adp)
resources.getDimensionPixelSize(R.dimen._11asp)

JAVA

getResources().getDimensionPixelOffset(R.dimen._100adp);
getResources().getDimensionPixelOffset(R.dimen._11asp);

COMPARISION

+---------+-------------+---------------+-------------+--------------------+
| Unit    | Description | Units Per     | Density     | Same Physical Size |
|         |             | Physical Inch | Independent | On Every Screen    |
+---------+-------------+---------------+-------------+--------------------+
| px      | Pixels      | Varies        | No          | No                 |
+---------+-------------+---------------+-------------+--------------------+
| in      | Inches      | 1             | Yes         | Yes                |
+---------+-------------+---------------+-------------+--------------------+
| mm      | Millimeters | 25.4          | Yes         | Yes                |
+---------+-------------+---------------+-------------+--------------------+
| pt      | Points      | 72            | Yes         | Yes                |
+---------+-------------+---------------+-------------+--------------------+
| dp      | Density     | ~160          | Yes         | No                 |
|         | Independent |               |             |                    |
|         | Pixels      |               |             |                    |
+---------+-------------+---------------+-------------+--------------------+
| sp      | Scale       | ~160          | Yes         | No                 |
|         | Independent |               |             |                    |
|         | Pixels      |               |             |                    |
+---------+-------------+---------------+-------------+--------------------+
| adp     | Auto        | ~160          | Yes         | Yes                |
|         | Density     |               |             |                    |
|         | Independent |               |             |                    |
|         | Pixels      |               |             |                    |
+---------+-------------+---------------+-------------+--------------------+
| asp     | Auto        | ~160          | Yes         | Yes                |
|         | Scale       |               |             |                    |
|         | Independent |               |             |                    |
|         | Pixels      |               |             |                    |
+---------+-------------+---------------+-------------+--------------------+

More info can be also be found in the Google Design Documentation.

LIMITATION

Use it carefully! for example, in most cases you still need to design a different layout for tablets.

SUPPORT ❤️

Find this library useful? Support it by joining stargazers for this repository ⭐️
And follow me for my next creations 👍

LICENCE

Auto Adjust Dimension Android Kotlin Library by Aman Jham is licensed under a Apache License 2.0.

About

Dynamically auto adjust the sizes of dimension supporting multiple screens sizes.

Resources

Stars

Watchers

Forks

Packages

No packages published