Hi all, I'm having trouble drawing edge-to-edge wh...
# compose
e
Hi all, I'm having trouble drawing edge-to-edge when the status bar is hidden (works fine when status bar showing) - I can only draw beneath the blank area where the status bar would be when it's hidden. I'm using compose 1.3.0-beta02 and accompanist-systemuicontroller0.26.3 beta
Copy code
WindowCompat.setDecorFitsSystemWindows(window, false)
setContent {
  val systemUiController: SystemUiController = rememberSystemUiController()
  systemUiController.isStatusBarVisible = false
  // draw here
The layout inspector shows a ViewStub of height 42dp:
Copy code
DecorView
  LinearLayout
    action_mode_bar_stub - ViewStub   height 42dp
    content - FrameLayout
      ComposeView
    navigationBarBackground - View
    statusBarBackground - View
Any ideas ? UPDATE: I've found it draws correctly on an Android 12 & 13 emulators but not on Android 12 on a Samsung S10.
s
I’ve had luck doing this without having to do the
isStatusBarVisible
part, simply by doing
WindowCompat.setDecorFitsSystemWindows(window, false)
. Maybe take a look at how NiA does it? Take a look at the theme and maybe the values-v27 (and v23) one?
e
Thanks..I looked at NowInAndroid, in fact it makes the system bars transparent but doesn't hide them as I am doing (I want to be able to draw edge-to-edge and toggle system bar visibility). The following non-compose code works fine on api 31 and 33 level emulators but not on a Samsung S10 running Android 12 which leaves a blank ViewStub above my view after clicking, so I wonder if this is a Samsung problem.
Copy code
WindowCompat.setDecorFitsSystemWindows(window, false)
setContentView(R.layout.activity_main)
findViewById<View>(R.id.my_view)?.let {
    val controller = WindowCompat.getInsetsController(window, it.rootView)
    controller.systemBarsBehavior = WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE
    it.setOnClickListener { controller.hide(WindowInsetsCompat.Type.systemBars()) }
}
s
Ahaa okay I misunderstood you completely. You’re hiding those bars completely, something I’ve unfortunately never tried to do so I don’t have any more input sadly 😕 If Android 13 emulator and Android 13 Samsung device do in fact function differently that’s very odd. I wouldn’t know who to ping either so just hope someone else who knows looks at this 👀
a
Does the device in question have a cutout/pinhole/notch? You might need to adjust
layoutInDisplayCutoutMode
e
Bingo, many thanks...the phone is a Samsung Galaxy S10 with hole-punch camera cutout. I've added
Copy code
<item name="android:windowLayoutInDisplayCutoutMode">
    shortEdges <!-- default, shortEdges, or never -->
</item>
and working with & without compose. 🙂