Android 软键盘监听
约 63 字小于 1 分钟
2023-10-22
软键盘监听
ViewCompat.setOnApplyWindowInsetsListener(input, new androidx.core.view.OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsetsCompat onApplyWindowInsets(@NonNull View v, @NonNull WindowInsetsCompat insets) {
boolean imeVisible = insets.isVisible(WindowInsetsCompat.Type.ime());
int imeHeightInt = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom;
if (imeVisible) {
// 软键盘显示
} else {
// 软键盘隐藏
}
return insets;
}
}