dimsuz
06/21/2021, 10:22 AMRow where I dynamically render buttons with different properties and have the strange ripple behaviour: the button which wasn't interacted with shows ripple effect for some reason. Notice the button in the center (video in the thread). Any ideas why this happens?dimsuz
06/21/2021, 10:22 AMRichard Z
06/21/2021, 10:34 AMdimsuz
06/21/2021, 10:39 AMRichard Z
06/21/2021, 10:44 AMRichard Z
06/21/2021, 10:47 AMdimsuz
06/21/2021, 10:54 AMRichard Z
06/21/2021, 11:01 AMstyle to Textdimsuz
06/21/2021, 11:05 AMAlbert Chang
06/21/2021, 11:25 AM@Composable
fun MyButton(selected: Boolean) { ... }
@Composable
fun App() {
MyButton(selected = selectedState)
}
In this way both selected and unselected states are the same invocation.
If you use something like this:
@Composable
fun SelectedButton() { ... }
@Composable
fun UnselectedButton() { ... }
@Composable
fun App() {
if (selectedState) {
SelectedButton()
} else {
UnselectedButton()
}
}
it won't work as SelectedButton() and UnselectedButton() are not the same invocation. When you switch selectedState basically what happens is that the old button is removed and the new button is added.dimsuz
06/21/2021, 11:54 AM