title: Fullscreen DialogFragment with translucent StatusBar
body: <p>I have a DialogFragment which I want to show in fullscreen. I do however still want a StatusBar present, and the hardware buttons at the bottom. I also want to set a background color of the StatusBar (for Lollipop).</p>
  
  <p>My problem is that if I set the following flags in the DialogFragment:</p>
  
  <pre><code>getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);   
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
  </code></pre>
  
  <p>Both the StatusBar and Hardware keyboard becomes translucent, and the DialogFragment stretches behind these.</p>
  
  <p>Here is the code, which has been greatly reduced to become readable:</p>
  
  <pre><code>public class CardDetailsDialog extends DialogFragment {
  
  Setup parameters...
  
  public static CardDetailsDialog newInstance(final long cardId, final long projectId){
      CardDetailsDialog frag = new CardDetailsDialog();
      frag.setStyle(DialogFragment.STYLE_NORMAL, R.style.CardDetailsDialogStyle);
      return frag;
  }
  
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      if(getDialog() != null) {
          getDialog().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
          getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
          getDialog().getWindow().getAttributes().windowAnimations = R.style.DialogSlideAnimation;
          getDialog().getWindow().setLayout(LinearLayout.LayoutParams.MATCH_PARENT,
                  LinearLayout.LayoutParams.MATCH_PARENT);
          getDialog().getWindow().setStatusBarColor(Color.RED);
      }
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setHasOptionsMenu(true);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      super.onCreateView(inflater, container, savedInstanceState);
      View view = inflater.inflate(R.layout.card_details, container, false);
  
      Handle everything that happens inside the view...
  
      return view;
  }
  }
  </code></pre>
  
  <p>Here is the referred theme:</p>
  
  <pre><code>&lt;style name="CardDetailsDialogStyle" parent="@style/Theme.AppCompat.Light.Dialog" &gt;
      &lt;item name="android:windowBackground"&gt;@null&lt;/item&gt;
      &lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt;
      &lt;item name="android:windowFrame"&gt;@null&lt;/item&gt;
      &lt;item name="android:windowIsFloating"&gt;true&lt;/item&gt;
      &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt;
      &lt;item name="android:windowAnimationStyle"&gt;@android:style/Animation.Dialog&lt;/item&gt;
      &lt;item name="android:windowSoftInputMode"&gt;stateUnspecified|adjustPan&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>And the style of the fragment:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/pp.whiteBackgroundColor" &gt;
  
  &lt;android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/card_details_toolbar"
      android:layout_height="wrap_content"
      android:layout_width="match_parent"
      android:layout_alignParentTop="true"
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
      app:popupTheme="@style/PopupMenutheme"&gt;
  &lt;/android.support.v7.widget.Toolbar&gt;
  
      &lt;ScrollView
          android:id="@+id/details_scrollview"
          android:layout_height="wrap_content"
          android:layout_width="match_parent"&gt;
  
          All subview elements here...
  
      &lt;/ScrollView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>This is the result: <img src="https://i.stack.imgur.com/cppoj.png" alt="Screenshot"></p>
  
  <p>As you can see, the ToolBar extends over the StatusBar and hardware buttons. I don't know if I am approaching this correctly. Am I missing something?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is what the same view look likes when I remove</p>
  
  <pre><code>getDialog().getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/HiSv9.png" alt="enter image description here"></p>