看到了就记一记啊
@[toc]
前言
android:inputType
是开发中非常常用的字段了,但你知道他都有哪些取值吗?
先一起看一下吧,然后我们逐个说一下。
inputType
首先,要避免一个误区,这个是 输入类型,而不是显示类型,
所以在有些类型的解释上可能要注意这个问题。它更多的是影响了键盘或者其它识别的输入问题,比如候选项,比如实时的纠错和补全,或者其它数值问题。
当然,不可避免的它从输入的角度去限制了一部分展示的问题。
inputType设置有两种方式。
一种在代码中通过 setInputType(InputType.TYPE_CLASS_TEXT)
另一种非常常用了,xml布局中使用:android:inputType="text"
下面先列举我们在xml布局中能用的 inputType
都有哪些类型,稍后逐一看一下。
--> platforms/android-26/data/res/values/attres.xml#inputType
"none" 无限制类型
android:inputType="none"
There is no content type. The text is not editable.
没有内容类型。文本不可编辑。
翻译过来,是这么说的,但是。。。
这个类型还真可以编辑。。。
其实可以理解为普通无类型文本,不会出现什么候选处理
从输入类型的角度去看,可能就比较好理解了,输入法或者键盘键入不认为这是可以编辑的文本,就不会对这个文本做特别的处理。
也就是可能某种程度上会限制部分输入方式,比如不会提供候选内容,
比如,语音输入的限制,手写限制,或者其它识别情况
对应 InputType.TYPE_NULL
android:inputType="none"
editView.setInputType(InputType.TYPE_NULL)
"text" 普通文本类型
咱们最常用的,普通文本类型。
这个也啥好说的。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL
android:inputType="text"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL)
"textCapCharacters" 全部字符大写
输入的每个字符都默认大写。
只对有单词大小写的文字有影响,比如,中文他就影响不了,哈哈
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS
android:inputType="textCapCharacters"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS)
"textCapWords" 单词首字母大写
每个单词的首字母大写,其它都是小写。
只对有单词大小写的文字有影响,中文他也影响不了
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS
android:inputType="textCapWords"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS)
"textCapSentences" 句子首字母大写
每个句子的第一个字符大写,其它都是小写。
只对有大小写的文字有影响,中文他还是影响不了
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
android:inputType="textCapSentences"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES)
"textAutoCorrect" 自动修正
会自动帮你修订拼错的单词,是这么解释的,但是貌似也是中文无效。
场景:比如聊天吧,哈
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
android:inputType="textAutoCorrect"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT)
"textAutoComplete" 自动补全
文本编辑器(即应用程序)根据其自身的语义自动完成输入的文本,并在用户键入文本时将其呈现给用户。这通常意味着输入法不应该显示候选项本身,但可以期望编辑器从InputMethodSession提供自己的补全/候选项。displayCompletions()是编辑器调用InputMethodManager的结果。请注意,与TYPE_TEXT_FLAG_AUTO_CORRECT和TYPE_TEXT_FLAG_NO_SUGGESTIONS相比,TYPE_TEXT_FLAG_AUTO_COMPLETE意味着编辑器应该显示一个显示建议的界面,但它不提供自己的界面,而是依赖编辑器来传递完成/更正。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE
android:inputType="textAutoComplete"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE)
"textMultiLine" 多行输入
允许输入多行。
比较明显的变化就是弹出的输入法会包含enter换行键~
如果没有这个设置,一般不太会出现换行键。
这个可能就是很多app中聊天支持的问题根源~
注意:如果未设置此标志,并且文本字段没有最大长度限制,出于性能原因,框架会自动将字符的最大长度设置为5000。
这个提示是源码中的,我没试过这么大长度的,但是个人理解的可能是输入法自身的长度限制。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
android:inputType="textMultiLine"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE)
"textImeMultiLine" 输入法多行输入
与此关联的常规文本视图不应该是多行的,但是当全屏输入法提供文本时,如果可以,它应该使用多行。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE
android:inputType="textImeMultiLine"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE)
"textNoSuggestions" 无提示候选信息
输入法不需要显示任何基于字典的候选项。这对于不包含该语言中的单词且不受益于任何基于词典的补全或更正的文本视图非常有用。
设置之后,直接展示你所输入的内容,不做任何关联性提示
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
android:inputType="textNoSuggestions"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS)
"textUri" uri格式输入
输入为Uri格式文本
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI
android:inputType="textUri"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI)
"textEmailAddress" 邮件地址格式
输入为e-mail邮件地址。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
android:inputType="textEmailAddress"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS)
"textEmailSubject" 邮件主题
输入为e-mail邮件的标题主题。
有点像邮件类app的需求。
也可能是Android应用于自身邮件的设置。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT
android:inputType="textEmailSubject"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT)
"textShortMessage" 短消息信息模式
短消息信息模式。
内容比较少,类似短信啊,即时聊天啥的。
也可能是Android应用于自身短信的设置。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE
android:inputType="textShortMessage"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE)
"textLongMessage" 长消息信息模式
长消息信息模式
跟短相对吧,哈哈
比较正式的长消息内容,如邮件的正式内容等。
也可能是Android应用于自身邮件正文的设置。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE
android:inputType="textLongMessage"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE)
"textPersonName" 人名输入
外国人的那种人名。
可能是用于Android通讯录中的模式吧。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME
android:inputType="textPersonName"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME)
"textPostalAddress" 邮寄地址
我有点没分清
不清楚是实际地理地址,还是类似于咱们的那种邮编
我个人倾向前者
也可能是用于Android通讯录中的模式吧。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS
android:inputType="textPostalAddress"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS)
"textPassword" 密码格式
应该也算是常用格式之一了,输入之后会变成星号不可见
常用于用户密码输入。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD
android:inputType="textPassword"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
"textVisiblePassword" 密码可见格式
密码对用户可见
常用于用户密码输入。
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
android:inputType="textVisiblePassword"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD)
"textWebEditText" web表单格式
输入内容为web表单格式
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT
android:inputType="textWebEditText"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT)
"textFilter" 文本筛选
输入文本用于列表的内容筛选等功能
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_FILTER
android:inputType="textFilter"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_FILTER)
"textPhonetic" 拼音输入
输入为拼音内容
当然针对的是带拼音的语言,不仅仅是中文拼音
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PHONETIC
android:inputType="textPhonetic"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PHONETIC)
"textWebEmailAddress" web表单中添加邮件地址
和邮件地址模式一样
不过,用于web表单的输入
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS
android:inputType="textWebEmailAddress"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS)
"textWebPassword" web表单中添加密码
和密码模式一样
不过,用于web表单的输入
对应了 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD
android:inputType="textWebPassword"
editView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD)
"number" 数字格式
输入内容为数字,默认打开数字键盘
对应了 InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL
android:inputType="number"
editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_NORMAL)
"numberSigned" 有符号数字格式
输入内容为数字,可以输入正负号
默认打开数字键盘
对应了 InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED
android:inputType="numberSigned"
editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED)
"numberDecimal" 浮点数字格式
输入内容为数字,可以输入小数点了
默认打开数字键盘
对应了 InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
android:inputType="numberDecimal"
editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL)
"numberPassword" 纯数字密码格式
输入内容为数字格式的密码
默认打开数字键盘
对应了 InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD
android:inputType="numberPassword"
editView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD)
"phone" 电话号码模式
输入内容为电话号码
应该是可以输入数字加空格和横杠吧
稍后会尝试一下
默认打开数字键盘
对应了 InputType.TYPE_CLASS_PHONE
android:inputType="phone"
editView.setInputType(InputType.TYPE_CLASS_PHONE)
"datetime" 时间日期格式
即允许输入时间也可以输入日期
对应了 InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_NORMAL
android:inputType="datetime"
editView.setInputType(InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_NORMAL)
"date" 日期键盘
只允许输入日期格式
对应了 InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE
android:inputType="date"
editView.setInputType(InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE)
"time" 时间键盘
只允许输入时间格式
对应了 InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_TIME
android:inputType="time"
editView.setInputType(InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_TIME)
附录一: android.text.InputType
package android.text;
/**
* Bit definitions for an integer defining the basic content type of text
* held in an {@link Editable} object. Supported classes may be combined
* with variations and flags to indicate desired behaviors.
*
* Examples
*
*
* - A password field with with the password visible to the user:
*
- inputType = TYPE_CLASS_TEXT |
* TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
*
*
- A multi-line postal address with automatic capitalization:
*
- inputType = TYPE_CLASS_TEXT |
* TYPE_TEXT_VARIATION_POSTAL_ADDRESS |
* TYPE_TEXT_FLAG_MULTI_LINE
*
*
- A time field:
*
- inputType = TYPE_CLASS_DATETIME |
* TYPE_DATETIME_VARIATION_TIME
*
*/
public interface InputType {
/**
* Mask of bits that determine the overall class
* of text being given. Currently supported classes are:
* {@link #TYPE_CLASS_TEXT}, {@link #TYPE_CLASS_NUMBER},
* {@link #TYPE_CLASS_PHONE}, {@link #TYPE_CLASS_DATETIME}.
* IME authors: If the class is not one you
* understand, assume {@link #TYPE_CLASS_TEXT} with NO variation
* or flags.
*/
public static final int TYPE_MASK_CLASS = 0x0000000f;
/**
* Mask of bits that determine the variation of
* the base content class.
*/
public static final int TYPE_MASK_VARIATION = 0x00000ff0;
/**
* Mask of bits that provide addition bit flags
* of options.
*/
public static final int TYPE_MASK_FLAGS = 0x00fff000;
/**
* Special content type for when no explicit type has been specified.
* This should be interpreted to mean that the target input connection
* is not rich, it can not process and show things like candidate text nor
* retrieve the current text, so the input method will need to run in a
* limited "generate key events" mode, if it supports it. Note that some
* input methods may not support it, for example a voice-based input
* method will likely not be able to generate key events even if this
* flag is set.
*/
public static final int TYPE_NULL = 0x00000000;
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
* Class for normal text. This class supports the following flags (only
* one of which should be set):
* {@link #TYPE_TEXT_FLAG_CAP_CHARACTERS},
* {@link #TYPE_TEXT_FLAG_CAP_WORDS}, and.
* {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. It also supports the
* following variations:
* {@link #TYPE_TEXT_VARIATION_NORMAL}, and
* {@link #TYPE_TEXT_VARIATION_URI}. If you do not recognize the
* variation, normal should be assumed.
*/
public static final int TYPE_CLASS_TEXT = 0x00000001;
/**
* Flag for {@link #TYPE_CLASS_TEXT}: capitalize all characters. Overrides
* {@link #TYPE_TEXT_FLAG_CAP_WORDS} and
* {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. This value is explicitly defined
* to be the same as {@link TextUtils#CAP_MODE_CHARACTERS}. Of course,
* this only affects languages where there are upper-case and lower-case letters.
*/
public static final int TYPE_TEXT_FLAG_CAP_CHARACTERS = 0x00001000;
/**
* Flag for {@link #TYPE_CLASS_TEXT}: capitalize the first character of
* every word. Overrides {@link #TYPE_TEXT_FLAG_CAP_SENTENCES}. This
* value is explicitly defined
* to be the same as {@link TextUtils#CAP_MODE_WORDS}. Of course,
* this only affects languages where there are upper-case and lower-case letters.
*/
public static final int TYPE_TEXT_FLAG_CAP_WORDS = 0x00002000;
/**
* Flag for {@link #TYPE_CLASS_TEXT}: capitalize the first character of
* each sentence. This value is explicitly defined
* to be the same as {@link TextUtils#CAP_MODE_SENTENCES}. For example
* in English it means to capitalize after a period and a space (note that other
* languages may have different characters for period, or not use spaces,
* or use different grammatical rules). Of course,
* this only affects languages where there are upper-case and lower-case letters.
*/
public static final int TYPE_TEXT_FLAG_CAP_SENTENCES = 0x00004000;
/**
* Flag for {@link #TYPE_CLASS_TEXT}: the user is entering free-form
* text that should have auto-correction applied to it. Without this flag,
* the IME will not try to correct typos. You should always set this flag
* unless you really expect users to type non-words in this field, for
* example to choose a name for a character in a game.
* Contrast this with {@link #TYPE_TEXT_FLAG_AUTO_COMPLETE} and
* {@link #TYPE_TEXT_FLAG_NO_SUGGESTIONS}:
* {@code TYPE_TEXT_FLAG_AUTO_CORRECT} means that the IME will try to
* auto-correct typos as the user is typing, but does not define whether
* the IME offers an interface to show suggestions.
*/
public static final int TYPE_TEXT_FLAG_AUTO_CORRECT = 0x00008000;
/**
* Flag for {@link #TYPE_CLASS_TEXT}: the text editor (which means
* the application) is performing auto-completion of the text being entered
* based on its own semantics, which it will present to the user as they type.
* This generally means that the input method should not be showing
* candidates itself, but can expect the editor to supply its own
* completions/candidates from
* {@link android.view.inputmethod.InputMethodSession#displayCompletions
* InputMethodSession.displayCompletions()} as a result of the editor calling
* {@link android.view.inputmethod.InputMethodManager#displayCompletions
* InputMethodManager.displayCompletions()}.
* Note the contrast with {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} and
* {@link #TYPE_TEXT_FLAG_NO_SUGGESTIONS}:
* {@code TYPE_TEXT_FLAG_AUTO_COMPLETE} means the editor should show an
* interface for displaying suggestions, but instead of supplying its own
* it will rely on the Editor to pass completions/corrections.
*/
public static final int TYPE_TEXT_FLAG_AUTO_COMPLETE = 0x00010000;
/**
* Flag for {@link #TYPE_CLASS_TEXT}: multiple lines of text can be
* entered into the field. If this flag is not set, the text field
* will be constrained to a single line. The IME may also choose not to
* display an enter key when this flag is not set, as there should be no
* need to create new lines.
*/
public static final int TYPE_TEXT_FLAG_MULTI_LINE = 0x00020000;
/**
* Flag for {@link #TYPE_CLASS_TEXT}: the regular text view associated
* with this should not be multi-line, but when a fullscreen input method
* is providing text it should use multiple lines if it can.
*/
public static final int TYPE_TEXT_FLAG_IME_MULTI_LINE = 0x00040000;
/**
* Flag for {@link #TYPE_CLASS_TEXT}: the input method does not need to
* display any dictionary-based candidates. This is useful for text views that
* do not contain words from the language and do not benefit from any
* dictionary-based completions or corrections. It overrides the
* {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} value when set.
* Please avoid using this unless you are certain this is what you want.
* Many input methods need suggestions to work well, for example the ones
* based on gesture typing. Consider clearing
* {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} instead if you just do not
* want the IME to correct typos.
* Note the contrast with {@link #TYPE_TEXT_FLAG_AUTO_CORRECT} and
* {@link #TYPE_TEXT_FLAG_AUTO_COMPLETE}:
* {@code TYPE_TEXT_FLAG_NO_SUGGESTIONS} means the IME should never
* show an interface to display suggestions. Most IMEs will also take this to
* mean they should not try to auto-correct what the user is typing.
*/
public static final int TYPE_TEXT_FLAG_NO_SUGGESTIONS = 0x00080000;
// ----------------------------------------------------------------------
/**
* Default variation of {@link #TYPE_CLASS_TEXT}: plain old normal text.
*/
public static final int TYPE_TEXT_VARIATION_NORMAL = 0x00000000;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a URI.
*/
public static final int TYPE_TEXT_VARIATION_URI = 0x00000010;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering an e-mail address.
*/
public static final int TYPE_TEXT_VARIATION_EMAIL_ADDRESS = 0x00000020;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering the subject line of
* an e-mail.
*/
public static final int TYPE_TEXT_VARIATION_EMAIL_SUBJECT = 0x00000030;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a short, possibly informal
* message such as an instant message or a text message.
*/
public static final int TYPE_TEXT_VARIATION_SHORT_MESSAGE = 0x00000040;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering the content of a long, possibly
* formal message such as the body of an e-mail.
*/
public static final int TYPE_TEXT_VARIATION_LONG_MESSAGE = 0x00000050;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering the name of a person.
*/
public static final int TYPE_TEXT_VARIATION_PERSON_NAME = 0x00000060;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a postal mailing address.
*/
public static final int TYPE_TEXT_VARIATION_POSTAL_ADDRESS = 0x00000070;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a password.
*/
public static final int TYPE_TEXT_VARIATION_PASSWORD = 0x00000080;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering a password, which should
* be visible to the user.
*/
public static final int TYPE_TEXT_VARIATION_VISIBLE_PASSWORD = 0x00000090;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering text inside of a web form.
*/
public static final int TYPE_TEXT_VARIATION_WEB_EDIT_TEXT = 0x000000a0;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering text to filter contents
* of a list etc.
*/
public static final int TYPE_TEXT_VARIATION_FILTER = 0x000000b0;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering text for phonetic
* pronunciation, such as a phonetic name field in contacts. This is mostly
* useful for languages where one spelling may have several phonetic
* readings, like Japanese.
*/
public static final int TYPE_TEXT_VARIATION_PHONETIC = 0x000000c0;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering e-mail address inside
* of a web form. This was added in
* {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
* this API version or later to see this input type; if it doesn't, a request
* for this type will be seen as {@link #TYPE_TEXT_VARIATION_EMAIL_ADDRESS}
* when passed through {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
* EditorInfo.makeCompatible(int)}.
*/
public static final int TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS = 0x000000d0;
/**
* Variation of {@link #TYPE_CLASS_TEXT}: entering password inside
* of a web form. This was added in
* {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
* this API version or later to see this input type; if it doesn't, a request
* for this type will be seen as {@link #TYPE_TEXT_VARIATION_PASSWORD}
* when passed through {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
* EditorInfo.makeCompatible(int)}.
*/
public static final int TYPE_TEXT_VARIATION_WEB_PASSWORD = 0x000000e0;
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
* Class for numeric text. This class supports the following flags:
* {@link #TYPE_NUMBER_FLAG_SIGNED} and
* {@link #TYPE_NUMBER_FLAG_DECIMAL}. It also supports the following
* variations: {@link #TYPE_NUMBER_VARIATION_NORMAL} and
* {@link #TYPE_NUMBER_VARIATION_PASSWORD}.
*
IME authors: If you do not recognize
* the variation, normal should be assumed.
*/
public static final int TYPE_CLASS_NUMBER = 0x00000002;
/**
* Flag of {@link #TYPE_CLASS_NUMBER}: the number is signed, allowing
* a positive or negative sign at the start.
*/
public static final int TYPE_NUMBER_FLAG_SIGNED = 0x00001000;
/**
* Flag of {@link #TYPE_CLASS_NUMBER}: the number is decimal, allowing
* a decimal point to provide fractional values.
*/
public static final int TYPE_NUMBER_FLAG_DECIMAL = 0x00002000;
// ----------------------------------------------------------------------
/**
* Default variation of {@link #TYPE_CLASS_NUMBER}: plain normal
* numeric text. This was added in
* {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An IME must target
* this API version or later to see this input type; if it doesn't, a request
* for this type will be dropped when passed through
* {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
* EditorInfo.makeCompatible(int)}.
*/
public static final int TYPE_NUMBER_VARIATION_NORMAL = 0x00000000;
/**
* Variation of {@link #TYPE_CLASS_NUMBER}: entering a numeric password.
* This was added in {@link android.os.Build.VERSION_CODES#HONEYCOMB}. An
* IME must target this API version or later to see this input type; if it
* doesn't, a request for this type will be dropped when passed
* through {@link android.view.inputmethod.EditorInfo#makeCompatible(int)
* EditorInfo.makeCompatible(int)}.
*/
public static final int TYPE_NUMBER_VARIATION_PASSWORD = 0x00000010;
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
* Class for a phone number. This class currently supports no variations
* or flags.
*/
public static final int TYPE_CLASS_PHONE = 0x00000003;
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
/**
* Class for dates and times. It supports the
* following variations:
* {@link #TYPE_DATETIME_VARIATION_NORMAL}
* {@link #TYPE_DATETIME_VARIATION_DATE}, and
* {@link #TYPE_DATETIME_VARIATION_TIME}.
*/
public static final int TYPE_CLASS_DATETIME = 0x00000004;
/**
* Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
* both a date and time.
*/
public static final int TYPE_DATETIME_VARIATION_NORMAL = 0x00000000;
/**
* Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
* only a date.
*/
public static final int TYPE_DATETIME_VARIATION_DATE = 0x00000010;
/**
* Default variation of {@link #TYPE_CLASS_DATETIME}: allows entering
* only a time.
*/
public static final int TYPE_DATETIME_VARIATION_TIME = 0x00000020;
}
参考文献
Google Source: android.text.InputType
Google Source: R.styleable.TextView_inputType