I want to animate the placeholder of my SearchBar Composable just like the Google Play Store searchbar placeholder. I tried to do it, but it does not seem to be as subtle as the Google Play Store.
This is what I want to achieve,
This is what I have done so far,
Here is my code,
var showInitialPlaceholder by remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
delay(1000)
showInitialPlaceholder = false
}
SearchBar(
...
placeholder = {
Crossfade(targetState = showInitialPlaceholder) { isInitial ->
if (isInitial) {
Text("Google Play")
} else {
Text("Search...")
}
}
}
...
)


I've crated simple searchBox example. I used two
AnimatedVisibilityblocks for the placeholders because in the desired gif you can see second placeholder appearing after the initial one is hidden, soCrossfadeis not the best option.Basically there is:
slideInanimation of SearchBoxfadeOutanimation of initial placeholderfadeInanimation of final placeholderUnfortunately i don't have good eyes when it comes to these little details so i debugged it with Window animation scale turned on and implement it too. Maybe try to play with animation durations, delays and choose desired easing. Try this and see how it will work for you, hope it helps at least a little.