我正在使用自定义键盘。我在 onCreateCandidatesView() 中设置了 setCandidatesViewShown(true) 函数,问题是 UI 没有正确调整。
任何帮助将不胜感激..以下是我所做的
@Override
public View onCreateCandidatesView() {
LayoutInflater li = (LayoutInflater) getApplicationContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View wordBar = li.inflate(R.layout.wordbar, null);
LinearLayout ll = (LinearLayout) wordBar.findViewById(R.id.words);
Button voiceCmd = (Button) wordBar.findViewById(R.id.voiceword);
LinearLayout ll1 = null;
Button voiceCmd1 = null;
//comment this block in the event of showing only one keyboard so that we can only
//one autocorrect bar
if (isLargeScreen) {
ll1 = (LinearLayout) wordBar.findViewById(R.id.words1);
voiceCmd1 = (Button) wordBar.findViewById(R.id.voiceword1);
}
voiceCmd.setOnClickListener(voiceClickListener);
mCandidateView = new CandidateView(this);
mCandidateView.setService(this);
setCandidatesViewShown(true);
mCandidateView.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
ll.addView(mCandidateView);
return wordBar;
}
我有同样的问题。我在 Ced 的帖子中找到了答案here.
解决方案是将其添加到您的输入法服务中,
@Override public void onComputeInsets(InputMethodService.Insets outInsets) {
super.onComputeInsets(outInsets);
if (!isFullscreenMode()) {
outInsets.contentTopInsets = outInsets.visibleTopInsets;
}
}
候选视图故意不将应用程序向上推。来自doc,
请注意,由于候选视图往往会经常显示和隐藏,因此它不会像软输入视图那样影响应用程序 UI:它永远不会导致应用程序窗口调整大小,只会在需要时导致它们平移。用户查看当前焦点。
上面的黑客增加了“内容”区域以包括候选视图区域。该文档用于onComputeInsets
将帮助您理解这个概念。
计算 UI 中有趣的插图。默认实现使用候选框架的顶部作为可见插图,使用输入框架的顶部作为内容插图。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)