监听输入法键盘的弹起与隐藏,可实现输入法和工具栏无缝切换
- 示例
在布局中任意添加:
...
<cn.forward.androids.views.KeyboardLayout
android:id="@+id/keyboard_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
...
mKeyboardLayout = (KeyboardLayout) findViewById(R.id.keyboard_layout);
mKeyboardLayout.setKeyboardListener(new KeyboardLayout.KeyboardLayoutListener() {
@Override
public void onKeyboardStateChanged(boolean isActive, int keyboardHeight) {
if (isActive) { // 输入法打开
// ...
} else{
// ...
}
}
});
- 更多