To make the status bar transparent in Android Studio

Seren Kaya
Apr 14, 2024

--

Photo by Rubaitul Azad on Unsplash

If you’re creating an app and haven’t decided on the color of the status bar, why not make it transparent? Let’s see how it’s done.

Step 1: Create a project.

Step 2: Follow this path: app > res > values > themes > themes.xml. Then, open themes.xml and add the following code between the <style></style> tags.

<item name="android:windowTranslucentStatus">false</item>
<item name="android:statusBarColor">@android:color/transparent</item>

Step 3: For step 3, open the MainActivity.kt file and paste the following code in the onCreate function. And don’t forget to import WindowCompat :)

Here is the code you can copy easily

WindowCompat.setDecorFitsSystemWindows(
window,
false
)

Step 4: Run the project.

--

--