title: Android closing full screen view at the bottom is shunted off the screen
body: <p>I have a screen with a bottom toolbar aligned using the following styling</p>
  
  <pre><code>&lt;style name="BottomToolbar" &gt;
      &lt;item name="android:layout_width"&gt;match_parent&lt;/item&gt;
      &lt;item name="android:layout_height"&gt;wrap_content&lt;/item&gt;
      &lt;item name="android:background"&gt;@color/WHITE&lt;/item&gt;
      &lt;item name="android:layout_gravity"&gt;bottom&lt;/item&gt;
      &lt;item name="android:layout_alignParentBottom"&gt;true&lt;/item&gt;
      &lt;item name="android:minHeight"&gt;?attr/actionBarSize&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>When I first enter my screen the toolbar is nicely aligned to the bottom of the screen.</p>
  
  <p>However, If I go to full screen mode (which hides the toolbar) and then return to normal mode (which re-displays the toolbar) the toolbar is now placed slightly off the screen. It looks as if its shifted down the amount of the status bar that is hidden in full screen mode.  </p>
  
  <p><a href="https://i.stack.imgur.com/q4dTQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q4dTQ.png" alt="enter image description here"></a></p>
  
  <p>If I background my app and then foreground it, the bottom toolbar is rendered correctly.</p>
  
  <p>I have a bar at the top of the screen (instead of an appBar) and that is rendered in the correct place. I can not work out why it is misplacing the bottom toolbar.  </p>
  
  <p>Its as if when it is determining the bottom of the parent it is not adjusting for the fact its not full screen height anymore.  </p>
  
  <p><strong>What I have tried</strong></p>
  
  <p>I have tried setting "fitsSystemWindows="true"" on my toolbar when exiting full screen mode but that doesn't make a difference.  </p>
  
  <p>I have tried setting the toolbar to INVISIBLE rather than GONE when hiding it but that makes no difference.</p>
  
  <p><strong>EDIT 1 - Added Code snippet of how I go into and out of full screen</strong></p>
  
  <p>I go into full screen using the following</p>
  
  <pre><code>getActivity().getWindow().getDecorView().setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
      | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
      | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
      | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
      | View.SYSTEM_UI_FLAG_FULLSCREEN
      | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
  </code></pre>
  
  <p>I exit full screen by using the following code</p>
  
  <pre><code>getActivity().getWindow().getDecorView().setSystemUiVisibility(
      View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
  </code></pre>
  
  <p><strong>EDIT 2 - View is not shoved off the bottom, its height is too small</strong> </p>
  
  <p>It appears that the bottom view is not shoved off the bottom of the screen, its height is shrunk and smaller than it should be.</p>
  
  <p>The bottom view is a LinearLayout with its height set to "wrap_content" but it appears the height is not calculated correctly as its shorter than its contents and hence the bottom of its contents are cut off. </p>
  
  <p><strong>Edit 3 - devices the issues presents on</strong></p>
  
  <p>Further investigation showed the issue only presents on devices which do not have the on screen navigation bar. For example the issue is on my Samsung 10" Tablet but not on my Nexus 5x.</p>