How to force EditText to start text with capital letter?
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
The options for android:capitalize are
android:inputType="none", which won't automatically capitalize anything.
android:inputType="sentences", Which will capitalize the first word of each sentence.
android:inputType="words", Which Will Capitalize The First Letter Of Every Word.
android:inputType="characters", WHICH WILL CAPITALIZE EVERY CHARACTER.
Apparently it has been changed to inputType
instead of capitalize
Use
android:inputType="textPersonName|textCapWords"
as using only "textPersonName"
is not enough so name's first letters would be capitalized.
Similarly with postal addresses:
android:inputType="textPostalAddress|textCapSentences"
Add this in your XML
android:inputType="textCapWords"
android:inputType="textCapSentences"
will work for sentences. However, I needed to capitalize every word in a full name field.