0

See (sorry SOF won't let me upload an image)

This is what I am trying to achieve. I have a map view and I want the status bar to be transparent to make maps look like it's under the text of status bar (like in uber app). I use

 getWindow().setFlags(
    WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
    WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
    /*,WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS*/);

this tag to do that. But the problem is I also have 4 buttons (like bottom nav bar) in the bottom. When I use that tag those buttons get behind the navigation bar (software keys).

I think if I use 2 different layouts it'll work, like one layout for phones with NavBar, and one for phones with hardware keys. But I Just don't know how. I've tried using this function but either it doesn't work or I am implementing it wrong please Help.

public boolean hasNavBar (Resources resources) {
        int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
        return f= id > 0 && resources.getBoolean(id);
    }

And then using if(f==true), else to change layout and java files but this always gives false.

SDJ
  • 4,083
  • 1
  • 17
  • 35
Mandeep Bagga
  • 393
  • 4
  • 11

1 Answers1

0

Try this instead of LAYOUT_NO_LIMITS:

Window w = getWindow();
w.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
w.setStatusBarColor(0x00000000);

You'll also need to make sure that android:fitsSystemWindows is set to false in the view you want to be behind the status bar. I had to try several different versions of these layout flags, and this is what worked for me.

You shouldn't need different layouts for phones with an without navbar keys, the layout will fill the screen either up to the soft navigation bar, or if the phone doesn't have one, all the way to the bottom.

Cameron
  • 1,281
  • 1
  • 19
  • 40
  • It made the status bar white and text is also white, when in fact I've changed the color of status bar text as black. – Mandeep Bagga Jun 29 '19 at 17:47
  • See I have a map fragment that I want to blend till the top and the text of notification should floating be above it. Kinda like in UBER android app – Mandeep Bagga Jun 29 '19 at 17:54
  • Is fitsSystemWindows false for every parent layout? For example, if you have activity_main that's including map_view or something, the parent layout in both files would need to have fitsSystemWindows=false – Cameron Jun 29 '19 at 18:52
  • Okay, I've trying different iterations of your solution and here's what I found out(spoiler! Still no luck). SO firstly, (I also have a nav drawer btw) when I add w.setStatusBarColor in my main activity and then add fitsSystem false in the XML file(s) (like nav_header, drawer, etc basically everything linked to my main activity layout) the result is same as using setNoLimit tag , which means my bottom buttons are under navigation keys. I tried to add fitsSys false in just map fragment but it has no effect whatsoever. – Mandeep Bagga Jul 01 '19 at 06:41