Rejusting UI与candidateview自定义键盘可见 [英] Rejusting UI with candidateview visible in custom keyboard

查看:1569
本文介绍了Rejusting UI与candidateview自定义键盘可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作custome键盘。我已经设置setCandidatesViewShown在onCreateCandidatesView((真)函数)上,问题是UI犯规得到适当的调整。

任何帮助,将不胜感激。下面是我做了什么

  @覆盖
公共查看onCreateCandidatesView(){    LayoutInflater李=(LayoutInflater)getApplicationContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    查看wordBar = li.inflate(R.layout.wordbar,NULL);
    LL的LinearLayout =(的LinearLayout)wordBar.findViewById(R.id.words);
    按钮voiceCmd =(按钮)wordBar.findViewById(R.id.voiceword);
    LL1的LinearLayout = NULL;
    按钮voiceCmd1 = NULL;
    //在显示只有一个键盘,使我们不仅可以的情况下,评论此块
    // 1自动更正栏
    如果(isLargeScreen){
        LL1 =(的LinearLayout)wordBar.findViewById(R.id.words1);
        voiceCmd1 =(按钮)wordBar.findViewById(R.id.voiceword1);
    }    voiceCmd.setOnClickListener(voiceClickListener);    mCandidateView =新CandidateView(本);
    mCandidateView.setService(本);
    setCandidatesViewShown(真);
    mCandidateView.setLayoutParams(新的LayoutParams(
            LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));    ll.addView(mCandidateView);    返回wordBar;}


解决方案

我有同样的问题。我发现通过CED 这里帖子上的答案。

解决的办法是添加到您的输入法服务,

@覆盖公共无效onComputeInsets(InputMethodService.Insets outInsets){
    super.onComputeInsets(outInsets);
    如果(!isFullscreenMode()){
        outInsets.contentTopInsets = outInsets.visibleTopInsets;
    }
}

这是故意的候选视图不会向上推应用程序。从文档


  

请注意,由于候选视图趋于显示和隐藏了很多,它不以同样的方式作为软输入视图影响应用程序的用户界面:它不会造成应用程序窗口来调整,只引起它们被平移如果需要的话,供用户查看当前焦点。


上面的黑客增加了内容区域包括候选视图区域。为 onComputeInsets 商务部将帮助你理解这个概念。


  

计算有趣的插图到您的UI。默认实现使用的候选帧为可见光插图的顶部,并为内容插图输入帧的顶部。


I'm working on custome keyboard .I have set setCandidatesViewShown(true) function in onCreateCandidatesView() , problem is the UI doesnt get readjusted properly.

Any assistance would be greatful.. below is what I have done

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

}

解决方案

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.

这篇关于Rejusting UI与candidateview自定义键盘可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆