Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set upper case for TextView

I have TextView. I would like to show text in upper case mode. Is there attributed for upper case? Just I have text in strings.xml and I need use the line in several place as lower case and upper case.

like image 881
Tim Avatar asked Aug 28 '12 12:08

Tim


People also ask

How do you change text to all caps in Android?

You can add the android:textAllCaps="true" property to your xml file in the EditText. This will enforce the softinput keyboard to appear in all caps mode. The value you enter will appear in Uppercase.


2 Answers

In the layout XML, you can set the android:textAllCaps attribute on your TextView:

<TextView android:textAllCaps="true"></TextView> 
like image 122
Ben Hutchison Avatar answered Sep 20 '22 04:09

Ben Hutchison


Use String class method while setting the text to TextView as

tv.setText(strings.toUpperCase()); 

Have a look at this post for detail discussion.

EDIT: This was answered way back before API 14. As other answer mentioned here, textView.isAllCaps = true and its java methods were introduced from TextView. Please use those.

like image 40
Adil Soomro Avatar answered Sep 20 '22 04:09

Adil Soomro