lesincs
10/08/2024, 6:50 AMfontScale
in Density
?
I am working on a feature which users can change the fontScale
within the app. I thought doing sth like this would be elegant:
val density = LocalDensity.current.copy(fonScale = customizedFontScale)
CompositionLocalProvider(LocalDensity provides density) {
content()
}
However, Density
is an interface I can not copy it. Also I found the real implementation is DensityWithConverter
which is a private class I can not access it as well.
So is there anything I can do or any better approach?Zach Klippenstein (he/him) [MOD]
10/08/2024, 4:49 PMval parentDensity = LocalDensity.current
val myDensity = remember(parentDensity) {
object : Density by parentDensity {
// override whatever you want
}
}
// provide myDensity
lesincs
10/08/2024, 9:18 PM