【问题标题】:Height of status bar in Android with no Activity (IME)没有活动的Android中状态栏的高度(IME)
【发布时间】:2013-08-11 17:13:05
【问题描述】:

我正在尝试确定 Android 中状态栏的高度,.我找到了答案,但似乎都依赖于 Activity 对象(例如 activity.getWindow() )。但是,我正在开发一种输入法,它没有关联的活动对象。

有什么想法可以在 IME 中做到这一点吗?

【问题讨论】:

    标签: android statusbar ime


    【解决方案1】:

    这已在其他帖子中得到解答。 Here 和链接到 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;
    }
    

    【讨论】:

    • 谢谢。我没有得到这个答案的是 InputMethodService 也可以有一个 onCreate 方法(我使用的示例代码没有明确定义一个)。你提供的第二个链接有我需要的线索。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-25
    • 1970-01-01
    • 2012-12-13
    • 2021-04-26
    • 1970-01-01
    • 1970-01-01
    • 2014-11-16
    相关资源
    最近更新 更多