Zeming
03/23/2025, 12:58 AMoverride fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
MyDebugTheme {
Scaffold(modifier = Modifier) { innerPadding ->
TextField(
value = "",
onValueChange = { newText ->
},
placeholder = { Text("Input your content") },
modifier = Modifier.padding(innerPadding)
.fillMaxWidth()
)
}
}
}
}
Remove "Scaffold":
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// enableEdgeToEdge()
setContent {
MyDebugTheme {
TextField(
value = "",
onValueChange = { newText ->
},
placeholder = { Text("Input your content") },
modifier = Modifier.fillMaxWidth()
)
}
}
}
Zeming
03/23/2025, 1:02 AMChrimaeon
03/23/2025, 8:08 AMfillMaxSize
and when you render just the TextField
you added a fillMaxWidth
modifier so only the width is maxed and the height is just the content height.Chrimaeon
03/23/2025, 8:13 AMZeming
03/23/2025, 8:41 AMoverride fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
MyDebugTheme {
Scaffold { innerPadding ->
TextField(
value = "",
onValueChange = { newText ->
},
placeholder = { Text("Input your content") },
modifier = Modifier.padding(innerPadding)
.fillMaxWidth()
)
}
}
}
}
Chrimaeon
03/23/2025, 8:47 AMfillMaxSize
.
not sure if debug.hwui.show_dirty_regions
is optimized for Compose. It renders to a canvas and what I imagine, the canvas is only as big as its content and what you see is the “dirty” canvas.Zeming
03/23/2025, 8:55 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. But why both the TextField and the Text are redrawed?
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?Chrimaeon
03/23/2025, 8:59 AMChrimaeon
03/23/2025, 9:02 AMZeming
03/23/2025, 9:03 AMZeming
03/23/2025, 9:04 AMChrimaeon
03/23/2025, 9:06 AMZeming
03/23/2025, 9:10 AMChrimaeon
03/23/2025, 9:17 AMZeming
03/23/2025, 9:19 AM