Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/intuit/sdp

An Android lib that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size.
https://github.com/intuit/sdp

Last synced: about 1 month ago
JSON representation

An Android lib that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size.

Awesome Lists containing this project

README

        

![issues](https://img.shields.io/github/issues/intuit/sdp)
![Forks](https://img.shields.io/github/forks/intuit/sdp)
![Stars](https://img.shields.io/github/stars/intuit/sdp)
![Maven Central](https://img.shields.io/maven-central/v/com.intuit.sdp/sdp-android)
![License](https://img.shields.io/github/license/intuit/sdp)

# SDP - a scalable size unit
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.

for text views please refer to [ssp](https://github.com/intuit/ssp) which is based on the sp size unit for texts.

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

# Example
[Here](https://github.com/intuit/sdp/blob/master/sdp-android/src/main/res/layout/sdp_example.xml) is a single layout built using sdp:

![sdp example](https://github.com/intuit/sdp/blob/master/sdp_example.png)

And [here](https://github.com/intuit/sdp/blob/master/sdp-android/src/main/res/layout/dp_example.xml) is the same layout built using dp:

![dp example](https://github.com/intuit/sdp/blob/master/dp_example.png)

You can see that sdp scales with the screen size and the dp stays with the same size on all screen sizes.

# Getting Started

To add sdp to your project (Using Android Studio and Gradle):

add implementation 'com.intuit.sdp:sdp-android:1.1.1' to your build.gradle dependencies block.

for example:

```
dependencies {
implementation 'com.intuit.sdp:sdp-android:1.1.1'
}
```
See the [sdp_example.xml](https://github.com/intuit/sdp/blob/master/sdp-android/src/main/res/layout/sdp_example.xml) to see how to use to the sdp size unit.

For easy mapping of designs to sdp units, one can create designs with 300 pixels screen width - in this case each pixel in the design corresponds to 1 sdp.

# Note
The sdp size unit calculation includes some approximation due to some performance and usability constraints.