Android - overlay screen including status bar content
<p>I want to make an overlay screen which overlay entire screen including the status bar and navigation bar. </p>

<p>I spends few hours of Googling/research still no luck.</p>

<p>This is my code:</p>

<p><strong>MainActivity.java</strong> (launcher):</p>

<pre><code>package com.blogspot.diannaoxiaobai.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        startActivity(new Intent(this, Main2Activity.class));
    }
}
</code></pre>

<p><strong>activity_main.xml</strong>:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.blogspot.diannaoxiaobai.myapplication.MainActivity"&gt;

    &lt;TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!" /&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p><strong>Main2Activity.java</strong> (launch by <strong>MainActivity</strong>):</p>

<pre><code>package com.blogspot.diannaoxiaobai.myapplication;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;

public class Main2Activity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        //getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        setContentView(R.layout.activity_main2);
    }
}
</code></pre>

<p><strong>activity_main2.xml</strong>:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main2"
    android:background="#99ed3636"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context="com.blogspot.diannaoxiaobai.myapplication.Main2Activity"&gt;
    &lt;LinearLayout android:id="@+id/overlay_instruction"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:background="@android:color/transparent"
        android:clickable="true"&gt;

    &lt;/LinearLayout&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p><strong>AndroidManifest.xml</strong> (Only <code>android:theme="@style/Theme.Transparent"</code> added, the rest were auto generated):</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.blogspot.diannaoxiaobai.myapplication"&gt;

    &lt;application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"&gt;
        &lt;activity android:name=".MainActivity"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;

                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
        &lt;activity
            android:name=".Main2Activity"
            android:theme="@style/Theme.Transparent"&gt;&lt;/activity&gt;
    &lt;/application&gt;

&lt;/manifest&gt;
</code></pre>

<p><strong>styles.xml:</strong></p>

<pre><code>&lt;resources&gt;
    &lt;style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt;
        &lt;!-- Customize your theme here. --&gt;
        &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
        &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
        &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
    &lt;/style&gt;

    &lt;style name="Theme.Transparent" parent="android:Theme.Holo.NoActionBar.Fullscreen"&gt;
        &lt;item name="android:windowDrawsSystemBarBackgrounds"&gt;true&lt;/item&gt;
        &lt;item name="colorPrimary"&gt;@android:color/transparent&lt;/item&gt;
        &lt;item name="colorPrimaryDark"&gt;@android:color/transparent&lt;/item&gt;
        &lt;item name="android:windowBackground"&gt;@android:color/transparent&lt;/item&gt;
        &lt;item name="android:windowFullscreen"&gt;true&lt;/item&gt;
        &lt;item name="android:backgroundDimEnabled"&gt;false&lt;/item&gt;
        &lt;item name="android:windowContentOverlay"&gt;@null&lt;/item&gt;
        &lt;item name="android:windowIsTranslucent"&gt;true&lt;/item&gt;
        &lt;item name="android:windowTranslucentStatus"&gt;true&lt;/item&gt;
        &lt;item name="android:windowTranslucentNavigation"&gt;true&lt;/item&gt;
    &lt;/style&gt;

&lt;/resources&gt;
</code></pre>

<p>The screenshot when launched, it did success to overlay entire screen including both status bar and navigation bar, but the status bar content(e.g. clock, battery status) was gone:</p>

<p><a href="https://i.stack.imgur.com/XqQ5l.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XqQ5l.png" alt="enter image description here"></a></p>

<p>When I pressed back to dismissed Overlay Activity, the status bar content was come back:</p>

<p><a href="https://i.stack.imgur.com/EUK4B.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EUK4B.png" alt="enter image description here"></a></p>

<p>What I wanted is overlay the status bar without remove the content, how should I do it ? </p>