Android:关闭软键盘时显示空白 [英] Android: Displaying WhiteSpace When Closing Soft Keyboard

查看:477
本文介绍了Android:关闭软键盘时显示空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个布局,其中包含一个ListView和一个ListView下方的EditText,用于在列表视图中进行搜索.问题是,当我在搜索后关闭软键盘时,它会突然跳动并在关闭软键盘时显示空白.我已经尝试过AdjustPan,但是它将整个布局向上移动.

I have a layout which contains a ListView and a EditText below the ListView which is used for searching in list view. The problem is that when i close the soft keyboard after a search, it gives a jerk and shows white space while closing the soft keyboard. I have tried adjustPan, but it moves the whole layout up.

推荐答案

public static void hideKeyboard(Context context,View v)
    {
        InputMethodManager imm = (InputMethodManager)context.getSystemService(
                  Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

    }

希望这会有所帮助!

这篇关于Android:关闭软键盘时显示空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆