Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 1.3 KB

README.md

File metadata and controls

53 lines (41 loc) · 1.3 KB

aDp

See here why you need this: https://medium.com/@mohitsoni48/creating-pixel-perfect-ui-with-jetpack-compose-17376455f16b

How to Install

Add it in your root build.gradle at the end of repositories:

dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add the dependency

dependencies {
	implementation 'com.github.mohitsoni48:aDp:<Version>'
}

How to Use

Initialize ADp in you application class/ Launching Activity like this

ADp.initializeAdp(this.resources, <Your design width in px>)

Replace dp with aDp and sp with aSp in your Jetpcak Compose

Text(
     text = "This text uses aSp\nDimensions to box are in aDp",
     fontSize = 16.aSp,
     modifier = Modifier
     .background(
        Color.LightGray
     )
     .padding(vertical = 20.aDp)
     .width(300.aDp)
)

Liked my work?

ko-fi

Note: This library is not optimized for foldable phones and tablets. Also If your device supports configuration changes, you will need to initialize again on each configuration change