Joren Joren - 11 months ago 64
Android Question

Text-transform:uppercase equivalent in Android?

Does this exist? I need to make a TextView which is always uppercase.


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


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, an on the onTextChange method take the user input and replace it with the same text in uppercase.


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) {

public void afterTextChanged(Editable editable) {