1

My app recognizes the presence of the navigation bar at the bottom of the screen and moves its own buttons up and out of the way so as not to be obscured. It also recognizes when "swipe gestures" have been turned on and reduces the amount of space reserved at the bottom of the screen.

My problem is that some devices have a "taskbar" that can appear across the bottom that is independent of the navigation bar, though it will share that bar if both are enabled at the same time. I can't figure out how to detect this taskbar and determine its height so I can adjust my layout to avoid it. Any clues?

Craig
  • 3,253
  • 5
  • 29
  • 43

1 Answers1

0

As per documentation, it could be handled by the current insets API.

The new Taskbar is reported to applications as an Inset, even though a new inset API has not been introduced.

Although the Taskbar doesn't have its own inset type, its dimension can be retrieved using WindowInsetsCompat.Type.navigationBars() or WindowInsetsCompat.Type.systemBars().

Turns out they'll be introducing new insets API to handle that.

Zain
  • 37,492
  • 7
  • 60
  • 84
  • Yeah, but I need to do this today and have it work in previous versions (at least 12, which is where I think this showed up). – Craig Jan 10 '23 at 11:13
  • @Craig `setOnApplyWindowInsetsListener` callback should be triggered for any changes in the insets including the taskbar changes; you'd need to register it during the app lifecycle – Zain Jan 10 '23 at 15:22