- Android transparent status bar and actionbar
- 3 Answers 3
- Transparent status bar (with visible navigation bar)
- 5 Answers 5
- how to make fully Android Transparent Status bar
- how to make fully Android Transparent Status bar
- Why making android transparent status bar from java?
- So lets start :
- for kotlin developers
- So here is how this method work :
- completely transparent status bar and navigation bar on lollipop
- 11 Answers 11
- Update
- Original Answer
- 100% working code
- Completely Transparent StatusBar and NavigationBar
- Set StatusBar & NavigationBar height & Color:
- Theme at styles.xml:
- in AndroidManifest.xml:
- How to Have a Transparent Status Bar but Leave Navigation Bar Opaque?
- 5 Answers 5
Android transparent status bar and actionbar
I’ve done a few researches on this topic and I couldn’t find a complete solution so, step by step and with some trial and error, I finally find out how can we achieve these results: having a transparent or coloured Actionbar and Statusbar . See my answer bellow.
3 Answers 3
I’m developing an app that needs to look similar in all devices with >= API14 when it comes to actionbar and statusbar customization. I’ve finally found a solution and since it took a bit of my time I’ll share it to save some of yours. We start by using an appcompat-21 dependency.
Transparent Actionbar:
values/styles.xml:
values-v21/styles.xml:
Now you can use these themes in your AndroidManifest.xml to specify which activities will have a transparent or colored ActionBar :
Note: in API>=21 to get the Actionbar transparent you need to get the Statusbar transparent too, otherwise will not respect your colour styles and will stay light-grey.
Transparent Statusbar (only works with API>=19):
This one it’s pretty simple just use the following code:
But you’ll notice a funky result:
This happens because when the Statusbar is transparent the layout will use its height. To prevent this we just need to:
SOLUTION ONE:
Add this line android:fitsSystemWindows=»true» in your layout view container of whatever you want to be placed bellow the Actionbar:
SOLUTION TWO:
Add a few lines to our previous method:
Where R.id.bellow_actionbar will be the layout container view id of whatever we want to be placed bellow the Actionbar :
So this is it, it think I’m not forgetting something. In this example I didn’t use a Toolbar but I think it’ll have the same result. This is how I customize my Actionbar :
Note: this is an abstract class that extends ActionBarActivity
Hope it helps!
Источник
Transparent status bar (with visible navigation bar)
I know this question has been asked many times, but all of the answers either not working, or use deprecated code:
I want to achieve the same effect as latest google maps app:
- Fully transparent status bar (Only status bar. not navigation bar!)
- Non deprecated solution
WindowCompat.setDecorFitsSystemWindows(window, false) partially working as it also hides the navigation bar also
5 Answers 5
Step 1: To make the status bar transparent: add the below into the style themes.xml or sytles.xml :
Step 2: Then in activity to make the status bar overlaps with the activity:
The used window flags are deprecated as of API level 30, so they can be used till API level 29:
UPDATE For API-30
This doesn’t actually make the status bar transparent, it makes it translucent and will still have a shadow to it
This is right on API-30, and reason because setting true .
Actually the true is only required on API level 19. If your app is greater than that, you can dismiss it at all.
Anyways, the way to fix this is to override the themes.xml/styles.xml in API-30; i.e. to have a res\values-v30\themes.xml ; you can just add the main app theme like:
UPDATE 2 For API-30
Just discovered a bug on API 30 that the bottom navigation overlaps with the activity obscuring the bottom part of it, that probably couldn’t be discovered by the OP as they are using a map.
You can address overlaps by reacting to insets, which specify which parts of the screen intersect with system UI such as the navigation bar or the status bar. Intersecting can mean simply being displayed above the content, but it can also inform your app about system gestures, too.
So, we need to handle the System bars insets for API level 30+ to avoid your app overlapping with the navigation bar:
This requires the top root ViewGroup of the activity layout, and accordingly the LayoutParams need to be coasted appropriately.
Here I am using a ConstraintLayout as a root layout, and FrameLayout.LayoutParams :
This is tested on 8 devices/emulators on the range of API level 19 to API level 30.
Источник
how to make fully Android Transparent Status bar
how to make fully Android Transparent Status bar
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.
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.
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.
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.
Источник
completely transparent status bar and navigation bar on lollipop
I’m trying to make an android launcher. I want to achieve a completely transparent status bar and navigation bar, here is my theme xml file.
the last two items don’t work, there is still a shadow on lollipop.
This is what it looks like(note there is actually a shadow on status bar and navigation bar):
what I want to achieve (nova launcher):
how to make the status bar and navigation bar «transparent» instead of «translucent»?
11 Answers 11
Update
You can achieve the same effect programmatically on KitKat and afterward by setting the FLAG_LAYOUT_NO_LIMITS flag inside the Window .
If you set a background resource (like a color or a picture) to your layout, you will see the color or picture «below» the status bar.
Original Answer
It looks like android:windowTranslucentStatus and android:windowTranslucentNavigation should be true instead of false
Also, your transparent activity / container layout needs this property set:
[Source][1] [1]: https://stackoverflow.com/a/29311321/1549700
I use this since it keeps the height of the status bar and nav bar
This does require API 21+ however
For API 29 and above use
You can use this kotlin extension function it will set status bar fully transparent (on API 23+, View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR flag available on API 23+) and navigation bar (on API 27+, View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR flag available on API 27+) otherwise it will use the systemUiScrim color on API 21+
API 21+ API 27+
100% working code
Completely Transparent StatusBar and NavigationBar
Set StatusBar & NavigationBar height & Color:
in activity_main.xml:
in java code:
Theme at styles.xml:
in AndroidManifest.xml:
The following code is an example of what I use in my project:
You need to add android:windowDrawsSystemBarBackgrounds flag to you theme
Or call this in onCreate()
To draw your layout under statusbar :
Use CoordinatorLayout/DrawerLayout which already take care of the fitsSystemWindows parameter or create your own layout to like this:
For those who want a completely transparent status bar and navigation bar on KitKat and up there is a small conflict with using windowTranslucentNavigation with @Machado answer’s for Lollipop and to prevent that conflict separate the styles
styles.xml (v21)
You can also change the alpha of your colorPrimary and colorPrimaryDark to 00 and then add this to your onCreateMethod:
and also add this to your activity:
This is for the new guys like myself on Nativescript + Angular. I started off with one of the blank templates on the NTS marketplace. Then For my specific use, I need the status bar on top to be always transparent (similar to the iOS style) and the navbar (bottom) to be fully transparent (not translucent!) on some components/modules, while opaque in others. If everything is done according to the protocol set by NTS, you should have a main.ts (a prerequisite for my solution) similar to this
I separated my work into two pieces, top first, then the bottom. For the top I found this answer that worked. So you should have a main.ts file that looks like this.
Then to add transparency to the navbar, I followed this and I add this to line 24 of the main.ts file above. activity.getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Now mind you there are also the styles.xml files we have to respect, so my styles.xml file (App_Resources\Android\src\main\res\values\styles.xml) looks like this:
Took me about 2-3 days to figure out, hope this helps
Источник
How to Have a Transparent Status Bar but Leave Navigation Bar Opaque?
I want to have a transparent status bar on my app (so the background goes behind it) but I want the navigation bar at the bottom to stay black.
I can make both transparent by setting getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
I can make the top translucent (partially transparent) by setting true
However, I can’t make the top completely transparent without making the bottom transparent too. Using @android:color/transparent or similar doesn’t work.
Does anyone know how to make a fully transparent status bar without affecting the navigation bar?
5 Answers 5
To independently control the transluscency of the status and navigation bars on KitKat, you can simply use the window manager flags FLAG_TRANSLUSCENT_STATUS and FLAG_TRANSLUSCENT_NAVIGATION in the onCreate() method of your activity. However, on KitKat the system may draw a semi-opaque gradient scrim drawable over the status bar. This appears to be device-specific: on my KitKat device it’s fully transparent, but on Android Studio emulator it shows a scrim.
On Lolliop or later you can instead set the status bar colour using the Window#setStatusBarColor(int) method together with the FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS window manager flag. Note that you clear the FLAG_TRANSLUSCENT_STATUS flag in this case. If you want the colour to be transparent, that implies that your application supports full screen mode and sets the system UI visibility, so it’s down to your app to manage the status bar background colour.
Putting it all together would look something like this:
Источник