I think this will work. The trick is you must use:
display.getRealSize(size);
not
display.getSize(size);
To deal with your API 8 coding issue do something like this:
try {
display.getRealSize(size);
height = size.y;
} catch (NoSuchMethodError e) {
height = display.getHeight();
}
Only more recent API devices will have onscreen navigation buttons and thus need the new method, older devices will throw an exception but will not have onscreen navigation thus the older method is fine.
In case it needs to be said: Just because you have a minimumAPI level of 8 for your project doesn't mean you have to compile it at that level. I also use level 8 for minimum but my project mostly are compiled at level 13 (3.2) giving them access to a lot of new methods.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…