我有一个困扰我很久的小问题。我试图谷歌这个,但似乎没有人有同样的问题,我或不认为这是一个问题。当我在布局下的activity_my.xml中创建一个按钮时

 <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/button_1_name"
    android:id="@+id/button2"
    android:layout_marginTop="140dp"
    android:layout_below="@+id/textView"
    android:layout_centerHorizontal="true" />

我得到一个像这样的按钮

尽管我的字符串代码是:

<resources>

<string name="app_name">HelloWorld</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="button_1_name">BuTtOn 1</string>

我知道我在这里肯定错过了一些小东西,但我如何在按钮文本中得到小写/大写?

谢谢!


当前回答

在XML: android: textAllCaps = " false "

编程:

mbutton.setAllCaps(假);

其他回答

有三种方法。

1.在style.xml上添加下面的行来更改整个应用程序

<item name="android:textAllCaps">false</item>

2.使用

android:textAllCaps="false"

在layout-v21中

mButton.setTransformationMethod(null);

在XML中的元素(按钮或编辑文本)下添加这一行

android:textAllCaps=“false”

问候

你可以添加android:textAllCaps="false"按钮。

按钮文本可能会被应用于所有按钮的应用程序主题转换为大写。检查主题/样式文件设置属性android:textAllCaps。

我在TextView中遇到了这个问题。我试过了

android:textAllCaps="false", 
mbutton.setAllCaps(false);   
<item name="android:textAllCaps">false</item> 

这些对我都没用。最后我厌倦了,我有硬编码的文本,它是工作的。

tv.setText("Mytext");

tv是TextView的对象。但按照编码标准,这是一种糟糕的做法。

在按钮的.xml文件中添加这行——

android:textAllCaps="false"
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:buttonStyle">@style/Button</item>
</style>

<style name="Button" parent="Widget.AppCompat.Button">
    <item name="android:textAllCaps">false</item>
</style>