Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Display Cutout

Panini
April 13, 2018

Display Cutout

Panini

April 13, 2018
Tweet

More Decks by Panini

Other Decks in Programming

Transcript

  1. About Me • Matthew Vern / Panini • Twitter: @callipan

    Github: panpanini • Mercari, Inc • Android Engineer (US) • Kotlin可愛い
  2. Display Cutout support For devices like Essential Phone, or iPhone

    X which have a cutout in the display (for camera, etc).
  3. Display Cutout emulator Cutout only covers status bar, so there

    should be little affect to apps not using Fullscreen Activity
  4. Important Point Clock has moved! Notifications only show on the

    left Notifications will be hidden behind ..
  5. LAYOUT_IN_DISPLAY_CUTOUT_MODE There are three layout modes for handling the cutout

    in a fullscreen Activity: LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
  6. WindowInsetListener // API Level 20+ view.setOnApplyWindowInsetsListener { view, windowInsets ->

    val cutout: DisplayCutout? = windowInsets.displayCutout // Adjust view position based on cutout windowInsets.consumeDisplayCutout() }
  7. WindowInsetListener // API Level 20+ view.setOnApplyWindowInsetsListener { view, windowInsets ->

    val cutout: DisplayCutout? = windowInsets.displayCutout cutout?.bounds?.bounds?.let { view.translationX = it.right.toFloat() view.translationY = it.exactCenterY() - (view.measuredHeight() / 2) } windowInsets.consumeDisplayCutout() }
  8. Summary • Most apps don’t need to worry about DisplayCutout

    • Status bar height can change • WindowInsetListener to get cutout position • LAYOUT_IN_DISPLAY_CUTOUT_MODE for fullscreen Activities • Clock & Notifications only shown on the left-hand side of status bar