An android lib that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size. It can help Android developers with supporting multiple screens. This fork uses 390 as a baseline, providing consistent measurements between material design guidelines and sdp size on a regular modern phone.
Use it carefully! for example, in most cases you still need to design a different layout for tablets.
Here is a single layout built using sdp:
And here is the same layout built using dp:
You can see that sdp scales with the screen size and the dp stays with the same size on all screen sizes.
To add sdp to your project:
- Download this repository as ZIP file
- Unzip it
- Copy the content from Res folder to your project res folder
- enjoy
By default the library has measurements from 1sdp to 600 sdp, and negative measurements from -1sdp to -60sdp
If you want a liter version you can download the Lite branch, it goes from 1sdp to 200 sdp, and doesn't include negative units. You can get them
programatically by using context.resources.getDimension(R.dimen._1sdp) * your_desired_size
in kotlin or getContext()-getResources().getDimension(R.dimen._1sdp) * your_desired_size;
in java
For easy mapping of designs to sdp units, one can create designs with 390 pixels screen width - in this case each pixel in the design corresponds to 1 sdp.
The sdp size unit calculation includes some approximation due to some performance and usability constraints.