title: ActionBar overlaying YouTubePlayerSupportFragment from YouTube Player API
body: <p>I've got an activity extending <code>AppCompatActivity</code>, using a theme extending <code>Theme.AppCompat.Light.DarkActionBar</code>.
  This activity's view is a <code>LinearLayout</code> with a <code>VERTICAL</code> orientation containing the following views:</p>
  
  <ol>
  <li><p>A <code>FrameLayout</code> containing a <code>YouTubePlayerSupportFragment</code>. Note that I'm calling the following methods on the obtained <code>YouTubePlayer</code> on initialization success:</p>
  
  <pre><code>setPlayerStyle(PlayerStyle.CHROMELESS)
  addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT)
  </code></pre>
  
  <p>I also set an <code>onClickListener</code> on the player view, supposed to hide and show the <code>ActionBar</code> on demand.</p></li>
  <li><p>Another view containing video details and stuff</p></li>
  <li>Some bottom view</li>
  </ol>
  
  <p>Note that the activity calls <code>supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR_OVERLAY)</code> and that the <code>LinearLayout</code> has a top padding of <code>android.support.v7.appcompat.R.attr.actionBarSize</code>.</p>
  
  <p>In the <code>AndroidManifest.xml</code>, the activity has <code>android:configChanges="orientation|screenSize"</code> set.</p>
  
  <p>In the activity's <code>onConfigurationChanged</code> method, I'm checking for the screen orientation. If it's landscape, I'm "going fullscreen", if it's portrait, I'm going back to the normal layout.</p>
  
  <p>By "going fullscreen", I mean:</p>
  
  <ol>
  <li>Setting view n°2 and view n°3 <code>visibility</code> to <code>View.GONE</code></li>
  <li>Setting the activity's <code>supportActionBar</code> background color to some transparent color like <code>0x55000000</code></li>
  <li>Setting <code>getWindow().getDecorView().systemUiVisibility</code> to <code>View.SYSTEM_UI_FLAG_FULLSCREEN</code></li>
  <li>Changing the view n°1 <code>LayoutParams</code>, setting both <code>width</code> and <code>height</code> to <code>MATCH_PARENT</code></li>
  <li>Calling <code>setFullscreen(true)</code> on the <code>YouTubePlayer</code></li>
  </ol>
  
  <p>Now when I'm in my app, everything works in portrait mode: the video plays, the player is correctly placed just below the <code>ActionBar</code>. It continues to work as expected when going into landscape mode: everything disappears except the player (even the <code>ActionBar</code>). Then I click on the now fullscreen YouTube Player.</p>
  
  <p>The expected result would be that the <code>ActionBar</code> shows up, without interrupting the playback.</p>
  
  <p>The actual result is that both the system status bar and the ActionBar shows up, and the playback is interrupted with the following error: </p>
  
  <blockquote>
    <p>YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.support.v7.widget.ActionBarContainer{43744840 V.ED.... ........ 0,50-1280,162 #7f0d005b app:id/action_bar_container}. The view is inside the YouTubePlayerView, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 0, top: 50, right: 0, bottom: 558..</p>
  </blockquote>
  
  <p>The YouTubePlayer is supposed to let an ActionBar overlay it, as shown in the <a href="https://github.com/youtube/yt-android-player/blob/master/src/com/examples/youtubeapidemo/ActionBarDemoActivity.java" rel="nofollow">Overlay ActionBar Demo</a> found in the <a href="https://developers.google.com/youtube/android/player/sample-applications" rel="nofollow">Sample Applications</a>. So what's the problem here? I thought it was just checking for the view covering it being an ActionBar or not, so I don't understand how this exact error is even possible!</p>