Effect:

Here are a few things to note: Set the properties in style:

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
Copy the code

Set the theme when registering your Activity. For example:

 <activity
            android:name="com.tencent.connect.common.AssistActivity"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="behind"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"/>
Copy the code

Note: If this is not set, the system theme will be used by default

<! -- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <! -- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style>Copy the code

To make an activity/container layout that you want to have a transparent status bar you need to set this property:

android:fitsSystemWindows="true"
Copy the code

Where the view is initialized such as: Activity’s onCreate()

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow(); 
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, 
            WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }
Copy the code

Add it manually in dimens file when android API < 19

<? The XML version = "1.0" encoding = "utf-8"? > <resources> <dimen name="padding_status_bar_top">Copy the code

When the API is greater than 19: create a values-v19 folder. The default statusBar height of the newly created DIMens file system is 25dp

<? The XML version = "1.0" encoding = "utf-8"? > <resources> <dimen name="padding_status_bar_top">25dp</dimen> </resources>Copy the code

Share with you

I want to work my way up

Fly forward on the blades at the highest point

Let the wind blow dry tears and sweat

I want to work my way up

Waiting for the sun to watch its face

Little days have big dreams

I have my day

Let the wind blow dry tears and sweat

One day I will have my day