https://kotlinlang.org logo
#compose
Title
# compose
k

Klaas Kabini

02/21/2020, 10:18 AM
What is the difference between Px and IntPx?
z

Zach Klippenstein (he/him) [MOD]

02/21/2020, 2:35 PM
Look at the types - one is a wrapper around a float, one is a wrapper around an int.
l

Leland Richardson [G]

02/21/2020, 5:35 PM
@Zach Klippenstein (he/him) [MOD] is correct, although we are experimenting with removing these wrapper types for Px (just having Int/Float represent pixels), and only use a unit class for Dp. https://android-review.googlesource.com/c/platform/frameworks/support/+/1228350 We are still unsure if we will go this route though. There’s a lot of nuance in terms of in what situations you want to use Floats to calculate pixels and when you want to use Int
z

Zach Klippenstein (he/him) [MOD]

02/21/2020, 5:39 PM
Why remove them? I really like them, it makes it extremely clear what the meaning of dimension parameters is.
☝️ 1
l

Leland Richardson [G]

02/21/2020, 5:48 PM
we really like using inline classes to define units
but the difficulty here is that there are two inline classes defining the same unit
and we have found that that causes a lot of confusion
there is a separate but related experiment where we are trying to figure out if it is a reasonable thing to always use Float for pixels, in which case we could keep the wrapper class and just have
Px
which would wrap a float
👍 1
but making a change like that is a pretty big thing that effects a lot of fundamental subsystems of a ui framework and we are trying to be careful that this wouldn’t have bad long term consequences
👍 1