My Android advanced tutorial ------) Solve the Problem of automatic uppercase of English strings on the android Button
Today, I encountered a question about the Button: The English string on the android Button is automatically converted to uppercase, And the Android 5.1 version is running, as shown in:
Figure 1: Button
Figure 2: TextView
The code for defining this Button is as follows:
The TextView definition code is as follows:
Reference the same string contactList_addContact. The content of the string is as follows:
Add
However, the Button is displayed as ADD, while the TextView is displayed as Add. I have never met before, so I'm depressed. Other buttons are displayed normally as follows:
The two buttons are defined as follows:
The referenced string is:
Cancel
Save
Well, the above is the problem. As to why this problem occurs, I guess the Android 5.1 SDK has changed the default Style of the Button, and the Style has set textAllCaps to true by default, I have not studied it carefully. View the code selected by the system: Row 233rd of frameworks/base/core/res/values/styles_material.xml. The Code is as follows:
We can find that the textAllCaps attribute is set to true.
The following describes how to solve this problem. You only need to Add the android: textAllCaps = false attribute to the Add button definition. This attribute is used to set whether to use uppercase letters to render text.
The code is changed to the following:
Okay, so we can solve the problem. After the change, we will see the following: