Sergey Y.
02/24/2021, 8:04 PMHalil Ozercan
02/24/2021, 8:13 PMHalil Ozercan
02/24/2021, 8:14 PMThiago
02/24/2021, 8:25 PMThiago
02/24/2021, 8:28 PMLeland Richardson [G]
02/24/2021, 8:51 PMLocalDensity
. For instance, the lambda for Canvas has density so you can use 40.dp.toIntPx()
for instance, if you have a dp value.
In general, if you find yourself needing a density object, make sure you don’t already have one available before reaching for LocalDensity.current
Sergey Y.
02/24/2021, 9:42 PMLeland Richardson [G]
02/24/2021, 9:45 PM.toIntPx()
or something then i think that’s good feedback. I think there are some cases where the math you are using is already in px but when it’s hard coded like this example is, dp is usually what you wantSergey Y.
02/24/2021, 9:47 PMLeland Richardson [G]
02/24/2021, 9:48 PMSergey Y.
02/24/2021, 9:50 PM<https://developer.android.com/jetpack/compose/graphics#canvas>
<https://developer.android.com/jetpack/compose/animation#high-level-apis>
Sergey Y.
02/24/2021, 9:51 PMSergey Y.
02/24/2021, 9:53 PMThiago
02/24/2021, 10:28 PM.toIntPx()
to set stroke width in the screenshot above?Leland Richardson [G]
02/24/2021, 10:30 PM.toPx()
perhaps instead because it is accepting floats. but yeah, that’s roughly the gist of itLeland Richardson [G]
02/24/2021, 10:31 PM