I know this question has asked several times but non of the answers worked in my case.
I found some of the same sort of questions and answers in the following links , which didn't work for me at all.
LINK1
LINK2
In my layout file, I have defined my EditText as follows.
<EditText
android:id="@+id/test_editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:layout_marginTop="90dp"
android:inputType="textCapWords"
android:ems="10" >
Also in the Activity class in the onCreate
method I have added the following code.
EditText testEditText = (EditText) findViewById(R.id.test_editText);
testEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
If someone have experienced the same issue and solved it would like to hear what I have done wrong in my case. Thanks.
Edits...
Following above explained steps I am unable to make this get it done(Auto capitalizing the first letter of each word while user typing).
According to my code, When user typing it displays first charater in all the words (including first word) in lower case.
If you are using an Android phone and Gboard, you can capitalize the first letter of any word with three touches. First, double-tap the word in question to highlight the word, then tap the shift button (the up arrow) on the keyboard to capitalize the first letter. Done!
To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.
testEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
or android:inputType="textCapSentences"
will only work If your device keyboard Auto Capitalize Setting enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With