Ian Warwick
01/08/2020, 9:27 PMDp
to Px
is there any special helper yet with compose APIs ? 🙂toPx
but I cannot find it in Dp
however there is an IntPx.toPx()
...Zach Klippenstein (he/him) [MOD]
01/08/2020, 10:50 PMwithDensity
to get access to the toPx
function.
Example from https://medium.com/mindful-engineering/saying-hello-to-jetpack-compose-a96d9e9c4f77:
Text(
text = "Hello world!",
// apply theme as per requirement
style = TextStyle(
color = Color.Blue,
fontSize = +withDensity { 50.dp.toPx().value }),
textAlign = TextAlign.Center
)
Ian Warwick
01/08/2020, 11:07 PMval density = Density(+ambient(ContextAmbient))
val widthPx = +withDensity(density) { ovalWidth.toPx().value }
val heightPx = +withDensity(density) { ovalHeight.toPx().value }
Zach Klippenstein (he/him) [MOD]
01/09/2020, 1:02 AMIan Warwick
01/09/2020, 8:36 AMmatvei
01/09/2020, 12:24 PMIan Warwick
01/09/2020, 12:25 PM