Does this exist? I need to make a TextView which is always uppercase.
Try this:
<TextView android:textAllCaps="true" />
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) { } };
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