I Want it All, Owning The System Window and Consuming Insets

Why Draw Behind The Status Bar?

Living it all, and wanting it all

🎵 I want it all,
I want it all,
I want it all,
and I want it now 🎵

Insetting on WindowInsets

The StatusBar inset

Digging in

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
We’re drawing behind the status bar! But something is off..
  1. The invisible top inset view for the status bar (Dynamic)
  2. The actual content of our fragment (Static)
  3. The invisible padding view for the software keyboard (Dynamic)
Our layout sandwich
  1. Register our FragmentManager.FragmentLifecycleCallbacks on Activity creation to adjust insets for each fragment as it appears.
  2. Tell the activity we intend to draw behind the status bar and listen for the size of the Activity’s insets in setContentView. This gives us the basic insets we need to measure once per configuration change.
  3. Upon receiving our system insets in consumeSystemInsets, adjust the visibility of the inset views according to the currently displayed fragment. We use the TransitionManager to animate the shrinking and expanding to smoothen the transition.
  4. Repeat “3” each time a fragment comes into the fragment container.
Sandwiched Fragment with insets
Setting the gold standard for apps with a golden retriever. Apt.

That’s it!

Queen
Our fullscreen UI for adopting GOOD BOYES and GIRLES

--

--

Bloke.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store