https://kotlinlang.org logo
#compose
Title
# compose
o

oday

12/02/2023, 11:02 PM
hi, I'm trying to find out why Compose is enforcing these animations upon navigation to and from screens and bottom navigation items, I have not placed anything unique or specific to anything related to animations or anything of the sort to cause this, and it's not the same animation everytime too, any clue as to what might be causing this? I am not sure which file you'd like to look at to help me figure out why this is happening, but whatever you do want to look at I can share the source
sometimes it's a fade in/out animation, sometimes the entire screen appears to start from the top left and expand into view
c

Chris Sinco [G]

12/03/2023, 7:16 PM
Are you using Compose Navigation? What version? And I assume Material3?
o

oday

12/03/2023, 7:18 PM
yes compose navigation
2.7.5
and yes Material3
I figured it was something to do with Scaffold being in place for each screen that you saw, I made it to be 1 Scaffold, but the animation persists, now you can see it more clearly here
I tried to do this to the NavHost
Copy code
NavHost(
        modifier = modifier,
        navController = navController,
        startDestination = Screen.Books.route,
        enterTransition = {
            fadeIn(animationSpec = keyframes {
                durationMillis = 0; 0.01f at 0; 1f at 1
            })
        },
        exitTransition = {
            fadeOut(animationSpec = keyframes {
                durationMillis = 0; 0.01f at 0; 1f at 1
            })
        }
    ) {
but it didn't change how this animation was happening when you navigate to a destination that's part of NavigationBar (bottom), it still happened
s

Stylianos Gakis

12/04/2023, 4:51 PM
your screens are not taking up the entire screen’s size, so the “content” resizes to take up only as much space as it needs, and then when the new screen comes up which now takes up the entire screen, it animates the size too. Just make sure all your destinations are taking up the entire screen’s size.
o

oday

12/04/2023, 4:54 PM
Hmm fillMaxSize?
Or just don’t apply padding that comes with Scaffold?
s

Stylianos Gakis

12/04/2023, 4:54 PM
Yeah give that a try to all of your “root” composables. Definitely apply the padding that comes with scaffold, it’s there for a reason.
o

oday

12/04/2023, 4:55 PM
Yea sure you’re right, yea I will try that
Thanks will let you know as this was the way I saw it happen from the beginning so definitely someone else will face this
s

Stylianos Gakis

12/04/2023, 4:58 PM
I’ve 100% seen this before and that was the issue. If you change the content of your screens to go full screen, the content would have no reason to do this size animation in the first place. I am 100% sure it’s the problem 😄
o

oday

12/04/2023, 9:27 PM
yup, that was it! Thanks a lot Stylianos!
🌟 1
by the way, and out of curiosity, i kept digging around and found this https://issuetracker.google.com/issues/297258205 I kept moving back in versions when i discovered that this is a legit bug, and
2.6.0
does not have this issue whatsoever navigates just fine without any razzle dazzle
and by the way, if you look at their star app "Now in Android", it uses 2.7.4 and it does have this bug as well
s

Stylianos Gakis

12/07/2023, 11:35 PM
Wait I am confused, does this issue still persist while having fillMaxSize on both destinations on some of the dependency versions?
4 Views