`
waterlife
  • 浏览: 65741 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Android Framework系列之IMF(一)

阅读更多

原创文章,转载请标注出处----

 

IMF(Input Method Frameworks)是Android输入法的Framework框架,其中最主要的是InputMethodService,他继承于AbstractInputMethodService。

 

它主要由以下几个组件构成,完成输入法的相关UI,和文字的输出。

 

1. Soft Input View

这是软键盘的Input Area,主要完成touch screen下和用户的交互输入。onCreateInputView() 被调用来进行soft inputview的实例化;onEvaluateInputViewShown() 决定是否显示soft inputview;当状态改变的时候,调用updateInputViewShown() 来重新决策是否显示soft inputview。

 

2. Candidates View

Candidates View也是输入法中一个相当重要的组件。当用户输入字符的时候,显示相关的列表。停止输入的时候,有会自动消失。onCreateCandidatesView() 来实例化自己的IME。和soft inputview不同的是Candidates View对整个UI布局不会产生影响。setCandidatesViewShown(boolean) 用来设置是否显示Candidates View。

 

3. 输出字符

字符的输出是InputMethodService最核心的功能,IME通过 InputConnection 从IMF来获得字符输出。并且通过不同的editor类型来获取相应的支持。通过 onFinishInput() onStartInput(EditorInfo, boolean) 方法来进行输入目标的切换。

 

另外,onInitializeInterface() 用于InputMethodService在执行的过程中配置的改变;

onBindInput() 切换一个新的输入通道;

onStartInput(EditorInfo, boolean) 处理一个新的输入。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics