android transparent status bar

I have been experimenting with status bar for about 2 days. As I go deep i got to know new things about status bar and how to achieve the transparent status bar.

This article is all about what i learned in that 2 days and also to help you so that you don’t have to research all like i did. If you already know much about status bar please put that in comment section i love to know that.

There are two ways to achieve the transparent status bar. As both example contains andro >

In this example we are using DrawerLayout and Coordinatorlayout and Navigation View as its child views.

Hello readers, You are here because you are interested in making your Android app’s status bar fully transparent as title of this post says “android transparent status bar”. You can do this from styles.xml or you can do this in JAVA code within an activity.

how to make fully Android Transparent Status bar.

Why making android transparent status bar from java?

We are doing this from java to avoid multiple changes in style.xml, color.xml etc. By this piece of code we will do everything in 1 place. If you have already tried doing changes in style.xml and got half transparent status bar then your problem will be solved by this method, because it will clear window flag and set new window flag to do its work.

Читайте также:  lenovo drivers официальный сайт

This method will work on Android version above 21, means this will work on devices having Android lollipop and above. On android version 19 and 20 (Android kitkat) fully transparent status bar will not work but we will make status bar Translucent instead. Below is screenshot from 3 devices having android version Jelly Bean, Kitkat and Android N to show you difference.

Fig.1 — android transparent status bar in lollipop and above. Fig.2 — android transparent status bar in kitkat and below.

So lets start :

Open class file of your activity, in my case I’m going to open LoginActivity.java file, and inside onCreate() method paste below code and run your app on Android version 21 or higher to see the changes.

below is java code, but if you are working on kotlin then scroll down to get kotlin code as well.

for kotlin developers

So here is how this method work :

First we will check android version is greater than 19 and less than 21 then we will set translusant status bar. and if android version is greater than 21 then we will set “android transparent status bar”. That’s it now you gave to do this in all your activites, or you can create a BaseActivity having code of “android transparent status bar” and extend all your activity with BaseActivity and you are done.

Pawneshwer Gupta

I am Software developer and web developer and also part time blogger.

I’ve searched the documentation but only found this: Link. Which is used to make the bar translucent? What I’m trying to do is to make the status bar completely transparent (as shown in the image below) and make it backwards compatible for APK | improve this question

Читайте также:  grim dawn где находятся сохранения игры

18 Answers 18

All you need to do is set these properties in your theme:

Your activity / container layout you wish to have a transparent status bar needs this property set:

It is generally not possible to perform this for sure on pre-kitkat, looks like you can do it but some strange code makes it so.

EDIT: I would recommend this lib: https://github.com/jgilfelt/SystemBarTint for lots of pre-lollipop status bar color control.

Well after much deliberation I’ve learned that the answer to totally disabling the translucency or any color placed on the status bar and navigation bar for lollipop is to set this flag on the window:

No other theme-ing is necessary, it produces something like this:

Оцените статью
Добавить комментарий

Adblock detector