Text-transform:uppercase equivalent in Android?

Solution 1:

Try this:

   <TextView 
            android:textAllCaps="true"
    />

Solution 2:

I don't see anything like this in the TextView attributes. However, you could just make the text uppercase before setting it:

textView.setText(text.toUpperCase());

If the TextView is an EditText and you want whatever the user types to be uppercase, you could implement a TextWatcher and use the EditText addTextChangedListener to add it, and on the onTextChange method take the user input and replace it with the same text in uppercase.

editText.addTextChangedListener(upperCaseTextWatcher);

final TextWatcher upperCaseTextWatcher = new TextWatcher() {

    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
    }

    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        editText.setText(editText.getText().toString().toUpperCase());
        editText.setSelection(editText.getText().toString().length());
    }

    public void afterTextChanged(Editable editable) {
    }
};

Solution 3:

For your EditText you can use InputFilter.AllCaps as filter

editText.setFilters(new InputFilter[]{new InputFilter.AllCaps()});

See: http://d.android.com/reference/android/text/InputFilter.AllCaps.html

Also you can specify your EditText via android:inputType:

<EditText
    ...
    android:inputType="textCapCharacters" />

Solution 4:

use

android:textAllCaps="true" 

this will make your all Textview capital.