Android, cellular and ICS - report screen size without bottom buttons

Well, on the honeycombs I have some functions that determine the screen size. This is sometimes used to dynamically create some interface elements. But the problem is that it includes a bottom panel with android buttons, which subtracts from your available screen size.

The android function Displaycan return the correct function (for example, the 1280x800 display will display 1280x740 as a display, it is a display that does not include the bottom buttons of the android), but the javascript function in the webview will only determine this actual size, so 1280x800 gets 1280x800, which is wrong. because the bottom panel is there.

How can I get the size of the bottom panel without hard coding, I can at least subtract it from the wrong integers of the screen size.

+5
source share
1 answer

I'm not sure if this is the best way, but here is how I do it (on Android 2.2, but this should also work on 3.x)

  • I create LinearLayout (FILL_PARENT)
  • I add my own look to it (for example, I subclass TextView) and I override onMeasure in it
  • in onMeasure, I call GetParent (). GetWidth () and GetParent (). GetHeight ()

This is probably not the answer you were looking for / hoping for, but at least it works for me.

+3
source

All Articles