1

Here is my EditText, textCapWords is not working for Samsung keypad. (Samsung S4). is there any workaround?

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:background="@android:color/transparent"
        android:imeOptions="actionDone"
        android:inputType="textCapWords"
        android:maxLength="15"
        android:padding="12dp"
        android:textSize="20sp" />
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
Jagadeesh
  • 239
  • 5
  • 9

5 Answers5

4

Did you try programatically?

youredttxt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);

OR

android:inputType="textCapWords|textCapSentences"

OR

AFAIK this one is deprecated but i don't know will it work or not,but you can try,

android:capitalize="words"
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
  • I had the same problem, resulting in indicating the `android:inputType="textCapSentences|textMultiLine"` did not work but finally indicating the same programmatically it worked. – francas Jul 16 '23 at 05:54
0

Can try this ... worked for me ...

android:inputType="textCapWords"

Or

android:inputType="textCapSentences"

Or

android:inputType="textCapWords"

For Samsung S5/S7 there is additional settings in settings named "Auto Capitalize" for making first charterer in Caps.

Tarit Ray
  • 944
  • 12
  • 24
0

With android:inputType="textCapWords", you can change your each first letter of word in the sentence. But maybe you change your keyboard to custom before, you should go to setting and change your keyboard to default. Hope this help you.

Danh Danh
  • 3
  • 1
  • 6
-2

Try this in XML:

android:textAllCaps="true"
-2

Used this Some devices Keyboard does n't support the capWords or disable to setting

this code Edittext each word first letter capital

 youredittext.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
            String capitalizedText = WordUtils.capitalize(youredittext.getText().toString());
            if (!capitalizedText.equals(youredittext.getText().toString())) {
                youredittext.addTextChangedListener(new TextWatcher() {
                    int mStart = 0;
                    @Override
                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

                    }

                    @Override
                    public void onTextChanged(CharSequence s, int start, int before, int count) {
                        mStart = start + count;
                    }

                    @Override
                    public void afterTextChanged(Editable s) {
                        youredittext.setSelection(mStart);
                        youredittext.removeTextChangedListener(this);
                    }
                });
                youredittext.setText(capitalizedText);
            }
        }
    });

Download the jar to import the WordUtils

https://www.dropbox.com/s/olfjyhfrghxvfs2/orgwordutils.jar?dl=0

Arjun saini
  • 4,223
  • 3
  • 23
  • 51