JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.24k stars 1.11k forks source link

Resizing the window leads to the UI elements scaling proportionally #4981

Closed MrZhuKeXin closed 1 week ago

MrZhuKeXin commented 1 week ago

Describe the bug When I resize the window, the UI elements scale proportionally, and after a certain delay, they return to the correct size.

Affected platforms

Versions

To Reproduce It's just the hellocompose code generated by ide. Steps to reproduce the behavior:

  1. Run this code snippet:
    @Composable
    fun HelloCompose() {
    var showContent by remember { mutableStateOf(false) }
    Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
        Button(onClick = { showContent = !showContent }) {
            Text("Click me!")
        }
        AnimatedVisibility(showContent) {
            val greeting = remember { Greeting().greet() }
            Column(Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
                Image(painterResource(Res.drawable.compose_multiplatform), null)
                Text("Compose: $greeting")
            }
        }
    }
    }
  2. run
  3. resize the window
  4. see the error

Expected behavior When I resize the window, the UI elements do not scale proportionally but instead display correctly according to their configuration. Additionally, the delay from proportional scaling to correct display seems to be longer compared to other software, such as those based on SWT.

Screenshots

https://github.com/JetBrains/compose-multiplatform/assets/28593015/e500602f-17f5-4e5d-bc5e-60daff4e79a4

Additional context Is this a known issue, or can this proportional scaling behavior be canceled through proper configuration? Can it be resolved in the future?

MatkovIvan commented 1 week ago

Another duplicate. Just previous issue opened before this one was about the same. See my comment there - https://github.com/JetBrains/compose-multiplatform/issues/4980#issuecomment-2172539689