1

I was looking everywhere for an answer with no success. I am using the values-xxhdpi folder to set my app's layout dimensions for the nexus 5, but as I switch to the galaxy S4 emulator (same resolution but without soft navigation keys) the layout is not ok any more.

Is there a way to target devices having the same resolution with and without the soft navigation at the bottom of the screen?

Thanks!

Edmond Tamas
  • 3,148
  • 9
  • 44
  • 89

2 Answers2

1

use:

ViewConfiguration.hasPermanentMenuKey()

NOTE This only works for SDK >= 14

EDITED:

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

if (hasBackKey && hasHomeKey) {
    // no navigation bar, unless it is enabled in the settings
} else {
    // 99% sure there's a navigation bar
}
Aditya Chauhan
  • 271
  • 3
  • 13
0

You can detect whether a device has a hardware menu key or not (the method you can use to achieve that, is described for example here) and apply a different set of resources yourself.

There's no way to do that "automatically" for example by forcing an app to use a different drawable folder.

Community
  • 1
  • 1
Bartek Lipinski
  • 30,698
  • 10
  • 94
  • 132