Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force EditText to start text with capital letter?

Tags:

android

I have an EditText and I need the text in it (when user types in) to be started with capital letter.

like image 840
Eugene Avatar asked Sep 12 '11 10:09

Eugene


People also ask

How do I get my texts to start with a capital letter?

All replies. Beginning of a sentence, go to Settings -> General -> Keyboard -> Turn on Caps Lock. If you want the entire message in capital letters-> tap the ⬆︎Capital letter key twice.

How do you make EditText all caps?

You can add the android:textAllCaps="true" property to your xml file in the EditText. This will enforce the softinput keyboard to appear in all caps mode. The value you enter will appear in Uppercase.

Can you set text in EditText?

In android, we can set the text of EditText control either while declaring it in Layout file or by using setText() method in Activity file.


1 Answers

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

like image 92
Maragues Avatar answered Sep 20 '22 18:09

Maragues