0

I am trying to determine the height to the status bar in Android, . I have found answers, but all seem to rely on the Activity object ( e.g., activity.getWindow() ). However, I am developing an input method, which does not have an associated activity object.

Any ideas how I can do this in an IME?

DaveWalley
  • 817
  • 10
  • 22

1 Answers1

0

This has been answered in other posts. Here and a response linked to here.

public int getStatusBarHeight() {
  int result = 0;
  int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
  if (resourceId > 0) {
      result = getResources().getDimensionPixelSize(resourceId);
  }
  return result;
}
Community
  • 1
  • 1
  • Thanks. The thing I didn't get for this answer is that an InputMethodService can also have an onCreate method (the sample code I was using did not explicitely define one). The second link you gave had the clue I needed. – DaveWalley Aug 11 '13 at 23:34