Android: Any simple way to get a completely transparent status bar? - android

This question has been asked several times -- and answered, but the answers don't seem to "add up".
Yes, one can simply set android:windowTranslucentStatus to true and set the WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS flag. (See Android Completely transparent Status Bar?) That produces a completely transparent status bar (in recent Android releases). That's great!
The issue is that this then results in the soft navigation bar being drawn over the lower contents (e.g. controls) within one's activity. I've tried resolving this with fitSystemWindows, but currently am clearly getting something wrong. Overall, it seems quite wrong that one has to get into any of this mess just to get a completely transparent vs. a translucent status bar!

Related

Black stripe over the navigation bar (AOSP)

I have a strange black bar (around 30 dp), which is over the navigation bar (see attached image).
It is preventing my app from fully wrapping it's view. Probably it is some system window border, which I can't yet find how to disable/resize.
It is observed in some apps, and in some it is not (which seems that applying some theme or window flag should remove it).
Here is what I've tried up to now:
Changed app theme to a different one (e.g. #android:style/Theme.DeviceDefault.Settings).
Applied this in oncreate:
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
Changed the nav bar size - it only gets smaller, but the black line stays in the same position
Using uiautomatorviewer doesn't seem to show the view (and id) of the navigation bar at all.
Any help for removing this line would be appreciated.
Hello again and thanks for the support.
Finally I've found the issue. It was due to the api which was used (android-23). After updating to android-29, the issue is resolved. Seems that somehow theming or windowing mechanism is affected by the old api (and the app does not cover the whole screen - the rest is covered by a black background).
PS: I needed to restart the phone in order this to be applied. Killing of the app after adb push didn't apply the setting.

How to set completely transparent navigation bar (NOT TRANSLUCENT) and keep receiving window inset updates

The image below is basically my goal, a completely transparent navigation bar (NOT TRANSLUCENT) and the content behind it keeps getting inset updates so it draws behind it, but does not get any UI covered by the navigation controls.
So far the only way possible to achieve the result in the image above is to set the flag FLAG_LAYOUT_NO_LIMITS to the activity. The problem is when that is done, the app no longer receives any insets whatsoever, with the exception of Gesture insets, if gesture navigation is enabled.
I've tried all the combinations I could think of, but so far I am completely unable to achieve 100% transparent navigation bar + window insets.
I assume that the reason why the navigation bar is not translucent when setting that flag is because the system window insets are now 0, as such the translucent area shrinks to 0 height, leaving the navigation controls without background.
I also tried setting
<item name="android:navigationBarColor">#android:color/transparent</item>
However, all this does is leave the navigation bar fully white and the content does not display behind it.
And I also had the following enabled and disabled for all the tests I conducted
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
I've researched high and above the Window Insets nightmare and there's one way to find the window insets via getWindow().getDecorView().getRootWindowInsets(), but then I will be falling to the problem of adding insets when they aren't needed (multi-window mode, for example) and I still won't get window inset updates, such as when the keyboard is opened.
I've watched ( #chris-banes ) Chris Banes' "Becoming a master window fitter", however this specific scenario is never covered.
Is this impossible? We can achieve this result for the status bar, but we will never be able to do the same for the navigation bar? If not, then how can this be achieved?
All I want is a 100% transparent (NOT TRANSLUCENT) navigation bar and the app keeps receiving the window insets with the expected values instead of 0 for all the values.
Chris Banes also has a more recent blog post, going through exactly what you are asking for:
https://medium.com/androiddevelopers/windowinsets-listeners-to-layouts-8f9ccc8fa4d1
In short, set the following system ui flags on the root view:
rootView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
To get the following result:
Then you can update the padding or margin of your view to make it available for touch events by adding an onApplyWindowInsetsListener:
bottomNav.setOnApplyWindowInsetsListener { view, insets ->
view.updatePadding(bottom = insets.systemWindowInsetBottom)
insets
}
For the full solution, I suggest you read the whole post, it's a good read and has helped me a lot.

Android : Actionbar Icon disappearing in UI

I have put two icons from Android Icon Packager for action bar. The Info Action appears brightly while the next one, Refresh Action is not appearing. I use both as holo_dark. I tried switching just the refresh action, and it appears very very dimly.
I've try reading many many stuffs I seem to find nothing about this topic.
EDIT: I have solved this problem by deleting the whole refresh icon and then remove the line
android:icon="#drawable/ic_action_refresh"
in the XML. I then re-added the icon and it works like a charm. Voted both answer for caring about my question
Use Icon from your Android Package Opposite to Your Theme.
For eg: If you are using Holo_Dark Theme in your Application use Holo_White Icon Set for it.

How to style the Status (Notification) bar in my activity

I have seen a few activities out there (and especially Home replacements) that actually have transparent/translucent status bar (and by that I really mean the status bar and not the title bar) and was wondering how they were doing it.
I've looked everywhere (Google, StackOverflow, etc) and haven't found a straight answer to this question, tried a lot of things myself but in vain... Now running out of options and the only one I have left is to set the activity FULLSCREEN and have a replacement for it (there are a few projects out there that offer replacements for the status bar, but I'd rather not go that far for such a simple task really).
Thanks.
EDIT:
I've found my answer after studying how others "did it"... They actually didn't.
My guess goes a little further than that since I think that my status bar IS actually transparent just like those applications, but the real difference is that they are using the 2D/live wallpapers rendered by Android as background which is rendered behind the status bar.
So the reason why I'm thinking I don't have a transparent status bar is because in my case only black is being rendered behind it...
I don't have a phone here with a opaque status bar but I'm pretty sure those apps will also have an opaque status bar (and not transparent).
You have looked every where except android developers official website.You can customize ur status(notification) bar.Here
is the link where u can get the custom notification bar tutorial.

How to Create Clickable on Icon in Status Bar to Run Function/Method/Code

Okay, this would be fairly simple in some other environments, but I can't figure out how to do it, or if its even possible in Android.
I have placed an icon on the status bar. I would like to run a method of another class whenever the user selects that icon. I've seen similar functionality used in volume icons that sit on the status bar that allow a user to raise or lower the volume when the icon is clicked. However, these icons are on the right side of the status bar, and from what I've seen, I'm not allowed to put an icon there. I don't know if that kind of functionality is available to left side icons.
So basically, I'm looking for how to run a function when a status bar icon is clicked. I don't want to open an activity, I just want to run a function.
What you're searching is probably related to the Android UI ActionBar pattern.
Regarding that I'd like to consider you to take a look at the Google I/O 2010 Android app. It contains many of these patterns and may help you out.
Summarizing, you have to create your own ActionBar (or Status Bar as you call it). You place your buttons, retrieve them via the findViewById(...) method and associate a click listener.

Categories

Resources