如何强制EditText以大写字母开头的文本? [英] How to force EditText to start text with capital letter?
问题描述
我有一个EditText
,我需要其中的文本(当用户键入时)以大写字母开头.
如果同时添加android:capitalize="sentences"
和android:inputType="text"
,请小心,因为后者似乎优先于第一个,并且输入内容不会大写./p>
有一个特定的inputType
可自动将首字母大写:
android:inputType="textCapSentences"
请参见 http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType
I have an EditText
and I need the text in it (when user types in) to be started with capital letter.
Be careful if you add both android:capitalize="sentences"
and android:inputType="text"
, as the latter seems to have priority over the first and the input will not be capitalized.
There's a specific inputType
for automatically capitalizing the first letter:
android:inputType="textCapSentences"
See http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType
这篇关于如何强制EditText以大写字母开头的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!