Hide system UI when ListPreference dialog is up
<p>So I have a custom <code>ListPreference</code> that I want to hide the <code>System UI Elements</code> once the dialog box is presented on the screen.</p>

<p><a href="https://i.stack.imgur.com/l5AZR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l5AZR.png" alt="Before"></a></p>

<p>I have found a post about how to hide element inside the dialog box itself (like the cancel button and title), however, I am not quite sure on how to access those particular pieces.</p>

<pre><code>@Override
protected void onPrepareDialogBuilder(AlertDialog.Builder builder) {
    super.onPrepareDialogBuilder(builder);
    //hide System UI elements here
}
</code></pre>

<p>This looks like a good place to make the changes to me, however, I am not 100% on it. </p>

<pre><code>View decorView = getWindow().getDecorView();
decorView.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>This is how the activities accomplish what I am trying to achieve.
<code>getView()</code> is also what I assume to be an approach to this, however, I am not quite sure if the dialog box is a Fragment or not.</p>

<p>Ok so I am able to hide the UI elements but it seem like there is still some sort of transparent bars left over.</p>

<p><a href="https://i.stack.imgur.com/sbVme.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sbVme.png" alt="After"></a> </p>

<p><strong>Does anyone know of a way to get rid of these remnant bars?</strong></p>

<pre><code>@Override
protected void showDialog(Bundle state) {
    super.showDialog(state);
    getDialog().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>This is how I am getting rid of the <code>System UI Elements</code>.</p>