Hello everyone,
I wonder if there's some way to overlay a View over the Navigation Bar.
I have an app which handles a color filter ovlaying the whole screen, but
starting from KitKat it's not covering the Navigation Bar anymore. I've
read it's a system restriction and I suppose it's mean to prevent abuse
from malicious apps, but I'm having many complains from my users asking to
cover the Navigation Bar, and it really is annoying when the filter doesn't
cover that area.
I'm able to lay the view behind the navigation bar, so the filter is
applied almost correctly when the navigation bar is translicent, but the
navitation buttons remain too bright over the filter.
Here's some code, I'm adding this view from a Service throught the
WindowManager#addView method:
This is the code I'm using to create and add the view:
final int overlayFlags =
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION |
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS |
WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
this.dimmerLayoutParams = new WindowManager.LayoutParams(overlayType,
overlayFlags, overlayPixelFormat);
this.dimmerLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
this.dimmerLayoutParams.x = 0;
this.dimmerLayoutParams.y = 0;
this.dimmerLayoutParams.width = screenWidth;
this.dimmerLayoutParams.height = screenHeight;
this.windowManager.addView(dimmerView, dimmerLayoutParams);
Some notes:
- The *WindowManager* is obtained previously and referenced in an instance
variable.
- *screenWidth* and *screenHeight* are obtained also previously by various
system-dependant methods which are out of scope, also setting the size to
10000x10000 works but consumes more memory.
- *dimmerView* is also created previously, and it just a new View() with
the service itself as context.
Ok now these are the results that I've got changing *overlayType*:
- SYSTEM_TYPE_OVERLAY: Lays over thw whole screen but behind the navigation
bar, so the navigation buttons and ofter the navigation bar itself "glow
furiously" as a user described, specially during Lollipop's battery saving
mode.
- SYSTEM_TYPE_ALERT: Behaves just like the SYSTEM_TYPE_OVERLAY, though I've
found this one supports touch events
- SYSTEM_TYPE_ERROR: In ICS and JB devices it lays efectively over the
navigation bar, but starting from KitKat it doesn't even lay behind it, it
just avoid the Navigation Bar area.
Has anyone faced this problem? Is there any solutions to this? I'm open to
hearing (in this case, reading) any suggestions.
Thanks everybody!
Mike
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/bad117c5-2770-4d75-a79a-ed6a68ce95c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.