chanjungskim
02/28/2023, 4:46 AMval densityDpi = LocalConfiguration.current.densityDpi
val screenHeightDp = LocalConfiguration.current.screenHeightDp
val fontScale = LocalDensity.current.fontScale
val density = (densityDpi / 160f) * (screenHeightDp / 360f)
CompositionLocalProvider(
LocalBackgroundTheme provides backgroundTheme,
LocalDensity provides Density(density, fontScale),
) {
MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}
Kirill Grouchnikov
02/28/2023, 4:50 AMchanjungskim
02/28/2023, 4:52 AMKirill Grouchnikov
02/28/2023, 4:55 AMchanjungskim
02/28/2023, 4:57 AMKirill Grouchnikov
02/28/2023, 4:58 AMchanjungskim
02/28/2023, 4:59 AMKirill Grouchnikov
02/28/2023, 5:07 AMchanjungskim
02/28/2023, 5:08 AMKirill Grouchnikov
02/28/2023, 5:09 AMchanjungskim
02/28/2023, 5:16 AMMarcin Wisniowski
02/28/2023, 11:07 AMchanjungskim
02/28/2023, 11:22 AMMarcin Wisniowski
02/28/2023, 11:36 AMchanjungskim
02/28/2023, 11:37 AMMarcin Wisniowski
02/28/2023, 11:48 AMchanjungskim
02/28/2023, 11:52 AMMarcin Wisniowski
02/28/2023, 11:55 AMModifier.graphicsLayer
https://developer.android.com/jetpack/compose/graphics/draw/modifiers#graphics-modifier-scale on the root of your UI to scale everything. It’s more of a zoom than a resize though. Build your UI with Dp so it looks good on 1920x1080 and scale on others. But still, I don’t think you should do that, build a responsive layout and it should work on a range of screen sizes.Kirill Grouchnikov
02/28/2023, 1:28 PMscreenHeightDp / 360f
Presumably this magic number comes from targeting a 1920x1080px Android device in landscape mode with 3x density (where 1dp is 3px)?
With this approach then, you are hardcoding your entire experience not even to a screen size, but a fixed screen height of 1080 pixels. Again, presumably, you are fine if your UI gets cut out horizontally on screens with lower aspect ratio - where the screen width in landscape mode is less than 1920 pixels?
If this is correct and you’re saying that other devices are “not really serious if it looks fine”, why not hardcode your experience to that 640x480dp screen and be done with it?