loloof64
11/25/2020, 9:32 AMval cellsSize = with(DensityAmbient.current) {
(size.toIntPx() * 0.1111) // Can I convert this result (which is px in Int) into an Sp unit, for a text ?
}
I've been searching at https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/package-summary. But did not find which one could be useful.André Kindwall
11/25/2020, 9:35 AMval cellsSize = with(DensityAmbient.current) {
(size.toPx() * 0.1111f).toSp()
}
loloof64
11/25/2020, 9:35 AMval cellsSize = with(DensityAmbient.current) {
Dp((size.toIntPx() * 0.1111).toFloat()).toSp()
}
Because toSp() is available from a Dp unit.André Kindwall
11/25/2020, 9:40 AMval cellsSize = with(DensityAmbient.current) {
(size * 0.1111f).toSp()
}
This is even betterloloof64
11/25/2020, 10:23 AM