This is an Android library allowing to auto adjust the density and scale pixels.
To use this library in your project Using Android Studio and Gradle:
implementation 'com.auto.adjust:dimens:1.0.9'
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 |
resources.getDimensionPixelSize(R.dimen._100adp)
resources.getDimensionPixelSize(R.dimen._11asp)
getResources().getDimensionPixelOffset(R.dimen._100adp);
getResources().getDimensionPixelOffset(R.dimen._11asp);
+---------+-------------+---------------+-------------+--------------------+
| 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.
Use it carefully! for example, in most cases you still need to design a different layout for tablets.
Find this library useful? Support it by joining stargazers for this repository ⭐️
And follow me for my next creations 👍
Auto Adjust Dimension Android Kotlin Library by Aman Jham is licensed under a Apache License 2.0.