1
votes

I'd like to programmatically determine if a device is presenting a tablet or phone style keyboard. Although there are many different Android soft-keyboard implementations, there are for the most part two distinct key layouts. One for phones and the other for tablets. Thanks for your help!

Note: I'm referring to the orientation of character keys to one another. On phone keyboards, the second two rows of characters are aligned, with the first row offset by 50%. Tablet keyboard are have a much more arbitrary offset that mimics a physical keyboard layout.

1

1 Answers

2
votes

Your concept of "tablet or phone style keyboard" does not reflect reality. There are input method editors that don't even have keys. The notion that "phone keyboards, the second two rows of characters are aligned, with the first row offset by 50%" may be true for some input method editors used on phones, but certainly not all, and it is certainly not a requirement.

So, you are certainly welcome to determine the screen size by any of the standard approaches (resource sets, Configuration, etc.). But you have no way to know:

  • if the input method editor the user is presently using has keys
  • if so, what the physical relationship is between those keys (e.g., "the second two rows of characters are aligned")