Zeming
03/23/2025, 9:24 AMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// enableEdgeToEdge()
setContent {
MyDebugTheme {
Column {
MyTextField()
Text("Demo")
}
}
}
}
}
@Composable
fun MyTextField() {
TextField(
value = "",
onValueChange = { newText ->
},
placeholder = { Text("Input your content") },
modifier = Modifier.fillMaxWidth()
)
}
I put a TextField and a Text in one Column, and only focus on the TextField to make the cursor flashed.
After set debug.hwui.show_dirty_regions to 1, I saw both the TextField and the Text are redraw (refer to the video attached) ?
Is it because the Column() is a inline function? And how should I change my code to only make the TextField redraw if there is no any change of the Text?
Thanks a lot!
Is it because the Column function is a inline function?
How can I change the source code to make it only redraw the TextField without Text?Jonathan
03/23/2025, 1:49 PMZeming
03/23/2025, 1:51 PMChrimaeon
03/23/2025, 1:54 PMZeming
03/23/2025, 1:58 PMJonathan
03/23/2025, 1:59 PMZeming
03/23/2025, 2:04 PMshikasd
03/23/2025, 2:40 PMshikasd
03/23/2025, 2:43 PMZeming
03/23/2025, 3:19 PMZeming
03/23/2025, 3:21 PMshikasd
03/23/2025, 3:22 PMZeming
03/23/2025, 3:25 PMshikasd
03/23/2025, 3:26 PMZeming
03/23/2025, 3:26 PMZeming
03/25/2025, 3:50 AMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// enableEdgeToEdge()
setContent {
MyDebugComposeTheme {
LazyColumn {
item { MyTextField() }
item { MyText() }
}
}
}
}
}
@Composable
fun MyTextField() {
TextField(
value = "", // 绑定状态
onValueChange = { newText ->
},
placeholder = { Text("Input your content") },
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
)
}
@Composable
fun MyText() {
Text("Demo")
}
shikasd
03/25/2025, 2:44 PM