[toc]
# Fullscreen App
## Navigation type
- Button Navigation
<img src="https://i.imgur.com/59n7rtM.png" width=300>
- Gesture Navigation (API 29 or above)
<img src="https://i.imgur.com/9EcP00l.png" width=280>
## Layout fullscreen
- Use `window.setFlag(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)`: layout the view behind status and navigation bar + make them transparent.
- Don't use `setDecorFitsSystemWindows(window, false)`: just layout the view behind navigation bar.
## Hide system bar
- Hide system bar:
- `WindowCompat.getInsetsController(window, window.decorView).hide(type)`
- Set behavior before hide:
- `BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE`: sticky mode
- Default and other flag: non-sticky mode.
- <img src="https://miro.medium.com/max/1100/1*7K55_lBht3gqSP8AzfERnA.png">
- **DON'T HIDE STATUS BAR**: it will offset the view.
- Change status bar content color instead: `isAppearanceLightStatusBars = true`
- System bars show:
- `WindowCompat.getInsetsController(window, window.decorView).show(type)`
## Handle gesture conflicts
- Gesture exclusion API:
- `setSystemGestureExclusionRects` to exclude from Back gesture.
- Limitation: 200dp on vertical (normal/non-sticky).
- Move views out of gesture area:
- See below section.
## Get gesture areas
- Type of insets:
- **System window inset**: area CURRENTLY obscured by system bar, IME and other system windows.
<img src="https://cdn-images-1.medium.com/fit/t/1600/480/1*UG3ipXuDiwcAmTIBwYvP0w.png" height=150>
- Methods: `getSystemWindowInsets()` or `View.onApplyWindowInsetsListener`.
- Use case: ensure `View` is not obscured (`BottomNavigationView`)
<img src="https://miro.medium.com/max/720/0*iXJpVAiLQYwGkjr2.webp" height=150>
- **Tappable element inset**: nearly the same as System window inset but smaller area, barely used.
- Methods: `getTappableElementInsets()`
- Use case: no, use System window inset instead.
- **Gesture inset**: area that gesture navigation uses.
- Types:
- All gestures.
- Mandatory gesture: gesture cannot be excluded by apps (home gesture & status bar gesture).
<img src="https://i.imgur.com/DdlVmN4.png" height=150>
- Methods: `getSystemGestureInsets()` or `getMandatorySystemGestureInsets()`
- Use case: ensure swipeable `View` is not conflict.
- **Stable insets**: area MIGHT BE obscured by system, IME and other system windows.
- Methods: `getStableInsets()`
- Use case: where system UI can be toggled on/off (immersive modes, video player, ...)
- Note:
- `onApplyWindowInsetsListener` can be called **multiple times**.
→ Set padding with `view.paddingBottom = view.paddingBottom + insets.bottom` will be called **multiple times**.
→ Cache the `view.paddingBottom` value instead.