【问题标题】:Android Close keyboard smoothlyAndroid 顺利关闭键盘
【发布时间】:2014-04-02 12:05:06
【问题描述】:

我正在使用以下代码从屏幕上隐藏软键盘

InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(
                mSearchView.getWindowToken(), 0);

当键盘关闭时,被覆盖一小段时间的空间出现白框,可以避免吗?

【问题讨论】:

  • 你用的是什么版本的操作系统??
  • @kAnNaN 我已经在 android 版本 2.3 到 4.4 上尝试过
  • 不确定,但请在您的代码之后尝试这一行 overridePendingTransition(0, 0);
  • @Kedarnath 没有成功

标签: android android-keypad


【解决方案1】:

尝试以下方法:

        InputMethodManager inputMethodManager = (InputMethodManager)  activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);

【讨论】:

  • 这并不能解决问题,关闭软键盘时仍然出现一个白框
【解决方案2】:

问题是我已经为清单中的活动设置了 windowSoftInputMode 属性来调整调整大小。

【讨论】:

    猜你喜欢
    • 2023-03-25
    • 1970-01-01
    • 2016-03-04
    • 2012-10-12
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多