安卓的EditText,软键盘显示/隐藏事件? [英] Android EditText, soft keyboard show/hide event?

查看:184
本文介绍了安卓的EditText,软键盘显示/隐藏事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能赶上软键盘是显示或隐藏的EditText事件?

Is it possible to catch the event that Soft Keyboard was shown or hidden for EditText?

推荐答案

嗨以下解决方法我会用:

Hi I'd used following workaround:

至于我的内容的看法是的LinearLayout的子类(可以是任何其它视图或视图组),我会重写onMeasure方法lilke如下:

As far as my content view is a subclass of LinearLayout (could be any other view or view group), I'd overridden onMeasure method lilke following:

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int proposedheight = MeasureSpec.getSize(heightMeasureSpec);
    final int actualHeight = getHeight();

    if (actualHeight > proposedheight){
        // Keyboard is shown
    } else {
        // Keyboard is hidden
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

这个解决办法帮我隐藏在键盘正显示出一些控制,并带回,否则。

This workaround helped me to hide some controls when keyboard is showing and bring back otherwise.

希望这将是有益的。

这篇关于安卓的EditText,软键盘显示/隐藏事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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