Skip to main content

How to capitalize every first letter of a word in Android 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);

Admin

Hi, I am Imran Alam, Full Stack Developer. Helping local businesses to enhance their reach to customers through Websites, Web / Mobile Application, and Digital Marketing. We offer a long range of services like Website Designing, Android Application, School Management System, LMS Software, Point of Sale (Pos) , SEO, Social media Marketing, and Technical Support as well.

Share via
Copy link
Powered by Social Snap