Hi everyone, is there any compose equivalent for `...
# compose
m
Hi everyone, is there any compose equivalent for
Copy code
android:windowBackground
in xml? And I'm talking about an app-wide solution.
a
No, there isn't. windowBackground as declared for an activity's theme in your manifest is declared as a static resource so that the android system can load it and display it without loading and running any of your app's code.
We've considered setups that might look compose-like for code that runs at build time to produce that kind of static resource, but such a system would need to take care not to set expectations that it executes at runtime like compose UI does. Anything like that is probably a ways off at best
m
Thank you, @Adam Powell
n
I’ll get a ride on this question… Even when the device is in light mode, I have two screens (Composables) which have a dark background. When I move from the first, to the second, I can see the white background very quickly. Is there an easy way to fix that? Here’s my structure:
Copy code
setContent {
    MyAppTheme {
        ProvideWindowInsets {
            Surface(color = AppTheme.colors.background) {
                AppNavHost(...)
            }
        }
    }
}
g
Maybe set dark theme for activity too?
n
Thanks @gildor. But I guess the
Surface
will overlap the activity… Don’t you think?
I tried to use a state to set the surface color, but didn’t work either.
g
Yes, but activity and it default theme is visible during content init, which is visible, especially of f app is starting (in case of main activity or app restart after return)
1
n
For this purpose I fixed using
android:windowDisablePreview
g
Not sure that it's good solution, isn't it means that there is no visual feedback during app start?
n
What I noticed is that there’s no blank/empty screen on app start.
g
Yes, there is no app loading indication at all, isn't it?
Properly implemented default theme is better solution imo, it solves app startup properly and will solve your issue with activity navigation
2
n
not actually… there’s a scale animation, but without the blank screen. Seems like the content is created and then is animated.
But my problem is not in the startup. The problem is when the app is loaded already.
Theme is light. Screen A is displayed and it has a dark background. Open screen B which also has a dark background. Then open screen C which has a background in according to theme.
The problem happens when I open screen B from A. I can see a quick white/light background
l
Seems like the content is created and then is animated.
So there can be a noticeable lag on slow devices already busy, and people might try to click the app icon twice or more.
n
oh! I forgot to update here… I fixed by setting the window background.