Android Softkeyboard 示例代码中,CandidateView 总是遮挡部分 UI。百度了下,中文网页竟然没有人讲这个如何解决。还是通过 StackOverflow 找到了答案。
https://stackoverflow.com/questions/11840627/rejusting-ui-with-candidateview-visible-in-custom-keyboard/
https://stackoverflow.com/questions/2762406/how-to-make-softkeyboard-candidate-view-not-block-application-view
原来,Android 的设计理念是,CandidateView 是一个时而显示,时而隐藏的东东,因此被设计为不能触发 UI 重新调整尺寸,而仅保证输入焦点露出来。
但是,这的确是一个很糟糕的用户体验。解决办法是:
The solution is to add this to your input method service,
@Override public void onComputeInsets(InputMethodService.Insets outInsets) {
super.onComputeInsets(outInsets);
if (!isFullscreenMode()) {
outInsets.contentTopInsets = outInsets.visibleTopInsets;
}
}