A question about Scaffold with contentWindowInsets...
# compose
t
A question about Scaffold with contentWindowInsets parameter. The following code gives me an innerPadding value with start and end == 0 on an emulator with API level 29 and below while on other emulators with API level > 29 the value is > 0 as expected by me (honestly I have only tested API level 28, 29, 33, 34, 35).
Scaffold(contentWindowInsets = WindowInsets.safeGestures,...) { innerPadding -> ... }
Obviously it's dependent on the API level. How to best deal with this?
s
Are you sure that one of those emulators isn't using the three button navigation system while the others use gesture navigation? That should change those insets afaik
t
@Stylianos Gakis thanks, interesting thought. I was not aware that this makes a difference (I'm not developing on Android for very long :)). But the question remains what is proper way to deal with that? Checking for a start and end padding > 0 otherwise adding the desired padding manually?
s
I would first ask why you want to use the
safeGestures
insets instead of just using the
safeDrawing
ones. Is there a particular reason?
t
That's a valid question. Well actually I want my main content to be inset a little bit left and right. Before I was simply applying a padding to my content but then I saw the 'contentWindowInset'-Parameter of the Scaffold and thought that might be the suggested was of doing it. Why safeGesture instead of safeDrawing? At the current state of my project a valid question. I could use safeContent as well. But it does behave exactly as safeGesture does - no insets at the start and the end. My main content shows a list view and in the future I maybe want to implement something like swipe to delete and then safeGesture is the appropriate inset value I guess. I'm "afraid" I have to dig into the official documentation to understand this issue better. 🙂
s
inset a little bit left and right
You most likely want to control that yourself, and to not have it be different depending on if someone uses 3 button or gesture navigation. Even in a swipe-to-delete environment, sure at the edges there will be some overlap where the back gesture will take precedent over your swipe gesture, however this would still most likely be what your users expect. Having a quite big empty space on the two sides will most likely look odd. But just give it all a try and make sure to test with both navigation setups to make sure it looks as you want it to. For reference, in our project we never use safeGestures for drawing content, but we use
safeDrawing
instead.
t
@Stylianos Gakis thanks a lot for your viable advice and feedback!
blob hug 1