If I have a pure compose app that is a single activity and I'm already using Chris Banes' Accompanis...
c
If I have a pure compose app that is a single activity and I'm already using Chris Banes' Accompanist for insets, and I want to be laid out edge to edge, what kind of theme comes out of the box that allows me to set a transparent navigation and status bar? The closest I could find is
android:theme="@android:style/Theme.Material.Light.NoActionBar.TranslucentDecor"
but I was hoping to find something like
Theme.Material.Light.NoActionBar.EdgeToEdge
.
j
I couldn’t find any, I’m overriding the theme and setting transparent
statusBarColor
and
windowLightStatusBar
as per https://medium.com/androiddevelopers/gesture-navigation-going-edge-to-edge-812f62e4e83e .
c
Hm. Yeah that's what I did in the "view" system, but since I have a completely compose app I was hoping that I never have to touch another theme/styles.xml ever again. lol @cb let me know if this is worth a bug report/feature request
👍 1
j
This has also recently been released which might help in this respect https://github.com/google/accompanist/tree/main/systemuicontroller . It allows setting those colors from within compose. Though AFAIR the XML based theme will still “take precedence” during the “splash screen” animation (i.e. that timeframe in between clicking on an app’s launcher icon and the single Activity’s
ComposeView
being loaded).
c
Interesting. So there may not be a way to escape an xml theme for launch theme anyway... Hmmm. Decisions decisions
And thanks for the tip on systemuiconteoller but it looks like it's for setting color of system bar icons and not making the bars transparent?
a
Android's UI system is based on windows and views and xml so no app is strictly pure compose. Compose UI also renders in a
ComposeView
and it's held by a window. Compose UI cannot completely eliminate xmls.
👍 1
j
And thanks for the tip on systemuiconteoller but it looks like it’s for setting color of system bar icons and not making the bars transparent?
It doesn’t seem so, check out the very first code examples here: https://google.github.io/accompanist/systemuicontroller/
Copy code
SideEffect {
    // Update all of the system bar colors to be transparent, and use
    // dark icons if we're in light theme
    systemUiController.setSystemBarsColor(
        color = Color.Transparent,
        darkIcons = useDarkIcons
    )
}
👍 2