title: How do I correctly implement Immersive Full-Screen Mode in Android?
body: <p>I have an application where I have a single activity that contains layers of fragments. I wanted to Switch between Immersive mode and Normal mode during some states of the app. Everything was fine until I call Hide System UI as per <a href="https://developer.android.com/training/system-ui/immersive.html" rel="nofollow noreferrer">Android Documentation</a>  </p>
  
  <p><a href="https://i.stack.imgur.com/iUIco.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iUIco.png" alt="Documentation Code"></a></p>
  
  <p>The sizes of the fragments started to go weird. No solutions found in stack overflow was any help. </p>
  
  <p>I have uploaded the project to <a href="https://github.com/cocoBavan/ImmersiveTest" rel="nofollow noreferrer">GitHub</a> . Could you please provide some insights on what I am doing wrong?</p>
  
  <ol>
  <li><p>Project When Started 
  <a href="https://i.stack.imgur.com/6YqxC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6YqxC.png" alt="Step One"></a></p></li>
  <li><p>When another Fragment was added to the same FrameLayout</p></li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/3FYzX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3FYzX.png" alt="Step Two"></a></p>
  
  <ol start="3">
  <li>When Third fragment was added to another FrameLayout while Immersive mode is triggered</li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/uqNtd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uqNtd.png" alt="Step 3"></a></p>
  
  <ol start="4">
  <li>Problem begins When Third Fragment's View minimised we trigger "Normal Mode". The top and bottom of the Previous fragments were cut out.
  <a href="https://i.stack.imgur.com/JsQwK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JsQwK.png" alt="Step 4"></a></li>
  </ol>
  
  <p>Moreover, Go Full Screen, Rotate and then Tap tap on PIP. It gets more ugly.</p>
  
  <p>I have uploaded the project to <a href="https://github.com/cocoBavan/ImmersiveTest" rel="nofollow noreferrer">GitHub</a> . Could you please provide some insights on what I am doing wrong?</p>