Skip to content

Instantly share code, notes, and snippets.

@jmadaminov
Created May 22, 2022 21:01
Show Gist options
  • Save jmadaminov/52160fe5c1859d857286a99ab7b031bb to your computer and use it in GitHub Desktop.
Save jmadaminov/52160fe5c1859d857286a99ab7b031bb to your computer and use it in GitHub Desktop.
Metrics
...
var screenWidthPx: Int
var screenWidthDp: Int
var cardWidthPx: Int
var cardWidthDp: Int
var cardHeightPx: Int
val cardHeightDp = 150
var cardMarginPx: Int
val cardMarginDp = 15
with(LocalDensity.current) {
screenWidthDp = LocalConfiguration.current.screenWidthDp
screenWidthPx = screenWidthDp.dp.toPx().toInt()
cardWidthPx = screenWidthPx / 2
cardWidthDp = screenWidthDp / 2
cardHeightPx = cardHeightDp.dp.toPx().toInt()
cardMarginPx = cardMarginDp.dp.toPx().toInt()
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment