title: Fullscreen video player - mediacontroller behind navigation bar
body: <p>I have a problem with mediacontroller which is hidden behind navigation bar (soft navigation keys on ICS). At first is OK (first picture), but when is navigation bar hidden for the first time, mediacontroller is resized to fit screen (correct), but is not resized back when navigation bar appears again (second picture). Also ad is moved behind (hidden for screenshot).</p>
  
  <p>If I understand documentation correct <em>fitsSystemWindows</em> should be responsible for resizing. But it's not working.</p>
  
  <p>How can I do that? Thanks for any help.</p>
  
  <p>I'm testing this on Galaxy Nexus.</p>
  
  <p>XML layout:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/playerLayout"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:animateLayoutChanges="true"
  android:background="@color/black" &gt;
  &lt;mynamespace.BKDVideoView
      android:id="@+id/videoview"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"/&gt;
  &lt;mynamespace.SubtitleTextView
      android:id="@+id/subtitleText"
      style="@style/SubtitleOverlayText"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="bottom|center_horizontal"
      android:layout_marginBottom="30dp"
      android:gravity="center"
      android:visibility="gone"
      android:fitsSystemWindows="true"
      android:animateLayoutChanges="true"/&gt;
  &lt;FrameLayout
      android:id="@+id/adLayout"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="top|right"
      android:fitsSystemWindows="true"
      android:animateLayoutChanges="true"/&gt;
  &lt;FrameLayout
      android:id="@+id/videoMediaControllerHolder"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      android:animateLayoutChanges="true"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>BKDVideoView is copy from GrepCode of VideoView with some customizations. I did the same for MediaController.
  In MediaController I'm calling hidding like that:</p>
  
  <pre><code>int newVis = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | SYSTEM_UI_FLAG_LAYOUT_STABLE;
      if (!visible)
      {
          newVis |= SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_HIDE_NAVIGATION;
      }
  
      // mSystemUiHolder -&gt; FrameLayout (playerLayout)
      mSystemUiHolder.setSystemUiVisibility(newVis);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/TVXWU.png" alt="When it&#39;s ok">
  <img src="https://i.stack.imgur.com/mG2Av.png" alt="When it&#39;s overlayed"></p>
  
  <p>Update: In case you have the same problem please check also comment in accepted answer. For views that needs to be fullscreen use sammyboy code. Thanks to both. Sorry, that I need too much time to figure this out and couldn't give you points :(</p>