Skip to main content

Android How to Capitalize Every First letter of a Word in EditText

If you want to capitalise the first letter of every word in a EditText, assign android:inputType=”textCapWords” to EditText.

Example:


       <EditText 
        android:id="@+id/mTxtCapitalize"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textCapWords"/>

The same can be done programmatically also as shown below.


TextView mTxtCapitalize = findViewById(R.id.mTxtCapitalize);
 
mTxtCapitalize.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Copy link
Powered by Social Snap