Latinime Input Method Analysis

Source: Internet
Author: User

The input method is set in the <input-method> label of RES/XML/method. xml. It mainly sets two attributes:

Android: settingsactivity, the input method setting program portal.

Android: isdefault. Is this default input method used by the system.

 

In addition, if the APK of the input method is directly pushed to/system/APP/or below, it is regarded as the system input method. If it is installed to/data/APP/or below as a third-party program, it is a third-party input method. The biggest difference between the two input methods is that when using the third-party input method, you must set the language and keyboard to start it manually.

 

The most important layout of letters is defined by kbd_qwerty.xml and kbd_qwerty_black.xml in res/XML/or lower. Other la S such as symbol layout and number layout are also under this directory. During operations, the program switches back and forth between these la S.

 

The analysis of these la S is completed by the keyboard (in the Framework) and its subclass latinime (in the source code of the Latin input method). The main methods involved include:

1. loadkeyboard: parse layout files

2. latinkeyboard. createkeyfromxml, keyboard. createkeyfromxml: Create a button from the XML file.

3. getdimensionorfraction: Get the value of an attribute. The format of this attribute value must be set to dimen (DIP, PX, SP, In, etc.) or fraction (percentage.

4. latinkeyboardbase. onbufferdraw: draws all the keys on a bitmap, and then renders this bitmap to the canvas passed by ondraw by the inherited viewondraw method.

 

When drawing the key, we mainly draw two things: Label and icon. For keys a, B, c, & and so on that can be expressed by characters, the label attribute is drawn. For keys that cannot be represented by characters such as shift and ALT, the icon attribute is drawn.

In addition, most keys only draw one of the icons or labels. A small number of keys are drawn. For example, the key qwertyuiop also has a small number in the upper right corner of the key. Each of these small numbers is an icon and is stored in the mnumberhinticons array of latinkeyboard. Qwertyuiop is a group of keys that are more special than others. They will have a reference backup in the latinkeyboard: mnumberhintkeys. Every time you press shift to update the keyboard layout, in addition to updating the labels of these keys, the updatenumberhintkeys method is called to assign values to their icons.

 

The problem this time is that latinime layout is messy. When this input method is enabled, the entire interface of the input method is squeezed into a very small rectangle at the bottom of the screen. After tracking, we found that the layout height width of the input method and the height width of each key are defined in dimens. xml. In dimens. XML, the units of these dimensions are in, which is a very small value after converting these units into pixels in the program. Finally, change the size unit to dip and set the appropriate value. It seems that after the system is transplanted to the Board, there is a problem in converting the in and pixels.

Latinime Input Method Analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.