r/androiddev • u/PrajwalCH • Aug 12 '26
Question [Help]: Jetpack Compose component flashing issue when list changes
When the list changes, the items are drawn on top of chip row for a brief amount of time. I have properly applied the id for each item. I am not sure what's causing the issue.
Below is the screen code preview, full code is available on GitHub.
Scaffold(
modifier = Modifier
.fillMaxSize()
.nestedScroll(scrollBehavior.nestedScrollConnection)
.then(modifier),
topBar = {
SearchProvidersScreenTopBar(
onNavigateBack = onNavigateBack,
onEnableAllSearchProviders = viewModel::enableAllSearchProviders,
onDisableAllSearchProviders = viewModel::disableAllSearchProviders,
onUpdateProtectionStatus = viewModel::updateProtectionStatus,
onResetToDefault = { showResetToDefaultDialog = true },
subtitle = {
val searchProvidersSummary = stringResource(
R.string.settings_search_providers_summary_format,
uiState.enabledProvidersCount,
uiState.totalNumProviders,
)
Text(searchProvidersSummary)
},
scrollBehavior = scrollBehavior,
)
},
snackbarHost = { SnackbarHost(snackbarHostState) },
floatingActionButton = {
FloatingActionButton(onClick = onNavigateToAddSearchProvider) {
Icon(
painter = painterResource(R.drawable.ic_add),
contentDescription = null,
)
}
},
) { innerPadding ->
Column(modifier = Modifier.padding(innerPadding)) {
SearchProviderFilterRow(
category = uiState.filter.category,
onCategorySelect = viewModel::toggleCategory,
protection = uiState.filter.protection,
onProtectionSelect = viewModel::toggleProviderProtection,
contentPadding = PaddingValues(horizontal = MaterialTheme.spaces.large),
)
SearchProviderList(
contentPadding = PaddingValues(
start = MaterialTheme.spaces.large,
top = MaterialTheme.spaces.large,
end = MaterialTheme.spaces.large,
bottom = 80.dp,
),
searchProviders = uiState.searchProviders,
onEnableSearchProvider = viewModel::enableSearchProvider,
onUnlockProtection = { searchProviderId, solverUrl ->
protectedProvider = ProtectedProvider(searchProviderId, solverUrl)
},
onEditConfig = onNavigateToEditSearchProvider,
onDeleteConfig = viewModel::deleteTorznabConfig,
)
}
}Update: This issue is now fixed. It was animation issue, not the recomposition. List items have Modifier.animateItem() applied and when list changes, the animation was rendering the list items on top of chip row for very short amount of time, meaning the animation was escaping the list bounds. After applying Modifier.clipToBounds() to SearchProviderList, the issue is now gone.
View all comments
Show parent comment
1
u/PrajwalCH Aug 13 '26 edited Aug 13 '26
I know it's confusing but I tested several things. I told Claude about my problem and after lengthy conversations, lot of testing, and weird hacky fix; I rechecked the flickering issue and noticed it was not the header that was flickering. I told that to Claude, it then recommended me to remove
Modifier.animateItem()from the list item if present and to test once again. When I did that, there was no flickering.If it was recomposition issue then after applying clipToBounds() the issue would still be present but it did fixed the issue.