是否可以捕获显示或隐藏EditText的软键盘的事件?
最佳答案
嗨,我用过以下解决方法:
至于我的内容 View 是LinearLayout的子类(可以是任何其他 View 或 View 组),我将重写onMeasure方法,方法如下:
@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);
}
这个解决方法可以帮助我在显示键盘时隐藏一些控件,否则可以重新显示。
希望这会有用。
关于android - Android EditText,软键盘显示/隐藏事件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3793093/