Rejusting UI with candidateview visible in custom keyboard

本小妞迷上赌 提交于 2019-11-30 07:44:56
tilish

I had the same problem. I found the answer on the post by Ced here.

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;
    }
}

It is intentional that the candidate view does not push the application upwards. From the doc,

Note that because the candidate view tends to be shown and hidden a lot, it does not impact the application UI in the same way as the soft input view: it will never cause application windows to resize, only cause them to be panned if needed for the user to see the current focus.

The hack above increases the "content" area to include the candidate view area. The doc for onComputeInsets will help you understand the concept.

Compute the interesting insets into your UI. The default implementation uses the top of the candidates frame for the visible insets, and the top of the input frame for the content insets.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!