Anonymous
Анимация BottomNavigation по какой-то причине добавляет белый фон перед запуском анимации.
Сообщение
Anonymous » 28 окт 2024, 00:03
Я пытаюсь добавить анимацию к слайду внешнего вида навигации по кнопкам снизу
Есть код:
Код: Выделить всё
@Composable
private fun BottomNavImpl() {
Scaffold(
bottomBar = {
var isBottomBarVisible: Boolean by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
delay(2000)
isBottomBarVisible = true
}
AnimatedVisibility(
visible = isBottomBarVisible,
enter = slideInVertically(
initialOffsetY = { it },
animationSpec = tween(
durationMillis = 500,
easing = FastOutSlowInEasing
)
),
exit = slideOutVertically(
targetOffsetY = { it },
animationSpec = tween(
durationMillis = 300,
easing = FastOutSlowInEasing
)
)
) {
NavigationBar(
containerColor = Color.Red,
) {
repeat(3) {
NavigationBarItem(
icon = {
Icon(
modifier = Modifier,
painter = painterResource(android.R.drawable.ic_menu_add),
contentDescription = null,
)
},
selected = false,
onClick = { }
)
}
}
}
},
content = { paddingValues ->
Box(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
.background(Color.Green)
) {
}
}
)
}
Он дает такой результат:
[img]
https://i.sstatic.net /65TGnHYBm.gif[/img]
Итак, проблема в том, что сначала появляется белый фон во всю высоту, а затем анимация.
Что такое Я пропал?
Подробнее здесь:
https://stackoverflow.com/questions/791 ... e-animatio
1730062996
Anonymous
Я пытаюсь добавить анимацию к слайду внешнего вида навигации по кнопкам снизу Есть код: [code]@Composable private fun BottomNavImpl() { Scaffold( bottomBar = { var isBottomBarVisible: Boolean by remember { mutableStateOf(false) } LaunchedEffect(Unit) { delay(2000) isBottomBarVisible = true } AnimatedVisibility( visible = isBottomBarVisible, enter = slideInVertically( initialOffsetY = { it }, animationSpec = tween( durationMillis = 500, easing = FastOutSlowInEasing ) ), exit = slideOutVertically( targetOffsetY = { it }, animationSpec = tween( durationMillis = 300, easing = FastOutSlowInEasing ) ) ) { NavigationBar( containerColor = Color.Red, ) { repeat(3) { NavigationBarItem( icon = { Icon( modifier = Modifier, painter = painterResource(android.R.drawable.ic_menu_add), contentDescription = null, ) }, selected = false, onClick = { } ) } } } }, content = { paddingValues -> Box( modifier = Modifier .fillMaxSize() .padding(paddingValues) .background(Color.Green) ) { } } ) } [/code] Он дает такой результат: [img]https://i.sstatic.net /65TGnHYBm.gif[/img] Итак, проблема в том, что сначала появляется белый фон во всю высоту, а затем анимация. Что такое Я пропал? Подробнее здесь: [url]https://stackoverflow.com/questions/79131498/bottomnavigation-animation-for-some-reason-adds-white-background-before-animatio[/url]