accompanist
accompanist copied to clipboard
[System UI Controller] Provide way to set layoutInDisplayCutoutMode
Actually calling
val systemUiController = rememberSystemUiController()
SideEffect {
systemUiController.isStatusBarVisible = false
}
hides correctly the status bar, but content doesn't fit the status bar empty space. I have this weird behavior with all version 0.20.0+ (including alphas and RCs)
Compose version is 1.1.0-rc01 Tested on Samsung SM G780G
Hi, could you share a bit more info? Are you using WindowCompat.setDecorFitsSystemWindows(window, false)?
Same issue here.
I use WindowCompat.setDecorFitsSystemWindows(window, false)
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Hi, querying for a bit more info here.
Are you using SystemUiController in combination with insets (either the deprecated accompanist/insets, or the new version built into androidx.foundation)?
Facing the same issue.
val systemUiController = rememberSystemUiController()
SideEffect {
systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = false)
}
Works and have the content draw under the status bar.
val systemUiController = rememberSystemUiController()
SideEffect {
systemUiController.isSystemBarsVisible = false
systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = false)
}
or
val systemUiController = rememberSystemUiController()
SideEffect {
systemUiController.isSystemBarsVisible = false
}
Does not work the status bar content is hidden but the insets for the status bar are now at 0 and nothing is drawn under the status bar.
I think I might have a lead. It looks like OP's device has a pinhole cutout, is that true for others in this thread as well?
The thread I'm pulling at is layoutInDisplayCutoutMode
If you change that via window.attributes.layoutInDisplayCutoutMode, does that change the behavior you're seeing?
Yes P6 Pro and all my emulator images have it too. I'll test later the option and report back.
So after quite a few tests, for whatever reason layoutInDisplayCutoutMode only works when set via the theme.xml not by code. (Android 12 P6 pro)
When setting layoutInDisplayCutoutMode to always in theme and systemUiController.isStatusBarVisible = false it will recompose 3 to 4 times the screen by moving up and down the content below / under / below / under / below / under the status bar.
Please note that I have migrated to Compose 1.2 alpha 7 insets handling.
Could you attach a video of that and provide a sample? In my testing I wasn't seeing the jumping behavior.
This could be something worth adding to accompanist, or at the least exposing the correct Window to change.
Here's the video.
Theme
<resources>
<!-- Base application theme. -->
<style name="Theme.Symfonium" parent="android:Theme.Material">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowLayoutInDisplayCutoutMode">always</item>
</style>
</resources>
Code is relatively simple
setContent {
CustomTheme {
SideEffect {
systemUiController.isStatusBarVisible = false
systemUiController.setSystemBarsColor(color = Color.Transparent, darkIcons = useDarkIcons)
}
The theme is an M3 theme that wrap an M2 theme
https://user-images.githubusercontent.com/932609/163030594-7a07de02-3727-4504-b8d6-a93407adbac7.mp4
The app is huge and private, and currently fighting with Android Auto validation team that refuse the app because it does not work when they don't purchase a paid app .... So tons of loose energy and time preventing me to try to build a full small repro.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Unstale, still need a way to hide status bar properly as request by my users :(
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Another one :) Is there a workaround / ugly way to get the proper window for layoutInDisplayCutoutMode?
For my use case asked by users the need to hide the the status bar fully is only for one screen.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Unstale we still need a way to do layoutInDisplayCutoutMode from code.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Another one :) The need for me at least, is that the user can enable a setting to have a part of the app full screen.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Is there anyway to add some kind of label to this issue to avoid the stale ?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Unstale :)
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Unstale :)
I am facing the same issue. As described above, I am setting
WindowCompat.setDecorFitsSystemWindows(window, false) in My Activity. Setting the status bar color to Transparent allows content to be visible through the status bar, but systemUiController.isStatusBarVisible = false leaves a black bar at the top of my screen through which content cannot be viewed. I am using a Galaxy Z Fold 4. The issue occurs on my outer screen which has the so-called "Pinhole" cutout (though I had always heard "hole-punch" to refer to that style of camera cutout) but not on my inner screen which has an under-display camera and therefore no cutout.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
Unstale :)
Seriously though, unless this part of accompanist is going to be deprecated and replaced by something in one of the standard compose libraries soon, I think this issue deserves some love.
As a direct solution, you can manually set layoutInDisplayCutoutMode via setting the window attributes, either from an Activity where you have the Window already, or using the same method to find the window that systemuicontroller.