1

I have a map fragment that is full screen and goes behind the navigation and status bars by setting fitsSystemWindows to "false". This however, means that the map objects such as the compass or the Google logo also fits outside the system window. I want to know if there is a way for only the elements to fit inside the window. As you can see with the picture below that the Google logo is sitting behind the navigation bar which I don't really like. I don't want to set padding as devices without soft keys will have the logo located out of place. Any working solution is appreciated.enter image description here

Lord Goderick
  • 965
  • 2
  • 14
  • 32

1 Answers1

1

I found a working solution by targeting devices with and without software keys and adjusting the padding so that map objects can fit within the frame in devices with software keys. Although this isn't an official method, it works.

 boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
 boolean hasHomeKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_HOME);

       if (hasBackKey && hasHomeKey) {
                googleMap.setPadding(35, 0, 0, 25); 
//for devices with hard keys//
            } else {
                googleMap.setPadding(35, 0, 0, 165);
//for devices with soft keys//
            }
        }

enter image description here

Lord Goderick
  • 965
  • 2
  • 14
  • 32